Public Class CCooling

    Dim c_p1 As Decimal, c_p2 As Decimal, c_cl As Decimal
    Dim b As Decimal, L As Decimal, n_G As Decimal, h_G As Decimal, L_max As Decimal, R As Decimal, z As Decimal
    Dim rho_cl As Decimal
    Dim eta_c_star_d As Decimal, eta_c_star_ce_sens As Decimal, eta_c_star_ce As Decimal, eta_c_d As Decimal, eta_c_ce As Decimal, eta_c_ce_sens As Decimal
    Dim Q_c_star_s As Decimal, Q_c_s As Decimal, Q_c_b As Decimal, Q_c_b_i As Decimal, Q_c_star_b_i As Decimal
    Dim Q_c_star_b As Decimal, Q_c_star_d As Decimal, Q_c_star_ce As Decimal, Q_c_d As Decimal, Q_c_ce As Decimal
    Dim Q_c_star_outg As Decimal, Q_z_outg_l As Decimal, Q_dot_c_outg As Decimal, Q_c_outg As Decimal, Q_c_outg_total As Decimal, Q_dot_z As Decimal
    Dim Q_c_ce_aux As Decimal, Q_z_aux_d_l As Decimal, Q_z_star_outg_l As Decimal
    Dim f_c_ce_aux As Decimal, f_Abgl As Decimal, f_e As Decimal
    Dim V_dot_z As Decimal
    Dim EER As Decimal, PLV_av As Decimal
    Dim P_d_hydr As Decimal, P_Pump As Decimal
    Dim beta_d_l As Decimal, e_d_l As Decimal
    Dim W_d_hydr_l As Decimal
    Dim Q_c_f_elektr As Decimal, Q_c_f_R_elektr As Decimal, Q_dot_R_outg As Decimal, Q_c_outg_therm As Decimal, Q_c_f As Decimal, Q_c_aux As Decimal
    Dim t_h_max As Integer
    Dim Q_c_g As Decimal, Q_c_g_v_i As Decimal, Q_dot_N As Decimal, Q_dot_d_in As Decimal
    Dim theta_VA As Decimal, theta_RA As Decimal, theta_HK_m_beta_h_d As Decimal, beta_h As Decimal, n_beta As Decimal
    Dim eta_k_100 As Decimal, eta_k_pl As Decimal, f As Decimal, e As Decimal, q_B_70 As Decimal, q_B_theta As Decimal, f_Hs_Hi As Decimal
    Dim Q_V_g_100 As Decimal, Q_dot_B_h As Decimal, Q_V_g_pl As Decimal, q_R_elektr As Decimal
    Dim beta_k_pl As Decimal, Delta_theta_z_cl As Decimal
    Dim Delta_P_WUE As Decimal, Delta_P_WUV As Decimal, Delta_P_RV As Decimal, Delta_p_z As Decimal
    Dim k_n As Decimal, f_1_av As Decimal, f_2_av As Decimal, f_R_av As Decimal, T_W_1_i As Decimal, l_min_i As Decimal
    Dim use_Oil As Decimal, use_LNG As Decimal, use_LPG As Decimal, use_Elec As Decimal, use_DH As Decimal

    '20100223 제거 i_count_chiller As Integer, 최적화중 사용안함
    'Dim i_count_zone As Integer, i_count_c_d As Integer
    Dim i_count_beta As Integer, k_n_index As Integer
    ' Dim i_count_renewable As Integer
    Dim i_HeatCool As Integer
    Dim theta_i As Decimal, Q_hp_outg As Decimal, Q_c_f_hp As Decimal, Q_c_g_hp_aux As Decimal
    Dim Q_chp_outg As Decimal, Q_c_f_chp As Decimal
    Dim system_type As Integer
    '==================================2010.2.21 수정
    Dim use_DC As Decimal
    Dim d_op_mth As Integer
    Dim d_op_max_mth As Integer

    Dim f_1_av_up As Decimal, f_1_av_dn As Decimal

    Dim Q_H_sol_out_m As Decimal, Q_W_sol_out_m As Decimal, W_sol_aux_m As Decimal
    Dim Q_h_outg_i As Decimal

    '==================================2010.04.02 수정
    'Dim priod_value As Decimal = 0
    Dim age As Decimal = 1 '//준공연도에 의한 경년변화값
    Dim age_heating As Decimal = 1.0F

    '==================================2013.08.18 추가
    Dim system_count As Decimal

    Dim 냉방용량합 As Decimal = 0
    Dim A_Q_c_b_i As Decimal = 0
    Dim A_Q_c_star_b_i As Decimal = 0
    Dim a_d_op_max_mth As Decimal = 0
    Dim a_t_h_max As Decimal = 0


    Public Overridable Sub Calc_CoolingSystem(ByVal i_count_month As Integer, ByVal theta_e As Decimal)

        pLog.LogEnable = True
        pLog.Add(String.Format(">> Calc_CoolingSystem i_count_month={0},theta_e={1}", i_count_month, theta_e))

       
        ' Dim i_count_profile As Integer
        use_DC = 0
        d_op_max_mth = 0
        '==================================2010.2.21 수정
        '==================================2010.04.02 수정
       
        Q_H_sol_out_m = 0
        Q_h_outg_i = 0
      

        '==================================2010.04.02 수정 / 0901비활성
        'For Each DRpriod As DS.tbl_DescRow In DSET.tbl_Desc.Select("cname<>'0'", "cname")
        '    priod_value = CSng(DRpriod.priod)
        'Next
        'If priod_value > 20 Then priod_value = 20
        'age = (1 - 0.01) ^ priod_value
        'age_heating = (1 - 0.005) ^ priod_value


        eta_c_star_d = 0.95 '건물 내 배관 적용
        eta_c_star_ce_sens = 1 '습도요구 편차없음 적용
        eta_c_star_ce = 0.9 '공조기기로 냉열전달에서 현열전달효율로 우선 0.9 적용
        Q_c_star_s = 0
        Q_c_s = 0 '(3.2.8-22)
        eta_c_d = 0.9 ' 우선 적용 추후 검토
        eta_c_ce = 1  ' 우선 적용 추후 검토
        eta_c_ce_sens = 0.9 '우선 적용 추후 검토
        f_c_ce_aux = 0.04 ' 표3.93 우선 적용 추후 검토
        f_Abgl = 1 '수리역학적으로 평형을 이룬 배관망
        Q_c_f = 0
        Q_c_aux = 0
        beta_k_pl = 0.3
        PLV_av = 1
        use_Oil = 0
        use_LNG = 0
        use_LPG = 0
        use_Elec = 0
        use_DH = 0
        i_HeatCool = 2
        system_type = 2
        system_count = 0
        냉방용량합 = 0                              '=================================2014.04.30 추가
        A_Q_c_b_i = 0                              '=================================2014.04.30 추가
        A_Q_c_star_b_i = 0                              '=================================2014.04.30 추가
        t_h_max = 0                                       '=================================2014.07.01 추가

        Dim Mon As String = "M" & Format(i_count_month, "00")


        'total(1,2,3,45,6,7)   / 냉방(1,2,3)
        '1,2,3존에(A) , 4,5,6존(B) 

        For Each dr냉방 As DS.tbl_nangbangkikiRow In DSET.tbl_nangbangkiki.Select("code<>'0' and 헤더적용=true", "code")

            pLog.Add(String.Format("헤더적용된 냉방기기={0}", dr냉방.code))

            Dim DrZRows() As DS.tbl_zoneRow = DSET.tbl_zone.Select("(공조냉방생산기기 = '" & dr냉방.code & "' and 냉난방공조 <> '기능없음' and (외기부하처리여부 = '예' or 냉난방공조 = '냉난방' or 냉난방공조 = '냉방') ) or (열생산냉방생산기기='" & dr냉방.code & "'  and 냉난방방식 <> '난방' and 냉난방방식 <> '기능없음') and code <> '0'", "code")
            If DrZRows.Length > 0 Then    '//존재하는것만 합친다. 150112- arin
                냉방용량합 += dr냉방.냉동기용량
            End If

            For Each Dr존 As DS.tbl_zoneRow In DrZRows
                Dim Drow분석() As DSR.월별에너지분석Row = CType(DSETR.월별에너지분석.Select("월='" & Mon & "' and 존='" & Dr존.code & "'"), DSR.월별에너지분석Row())
                system_count = TOSG(Dr존.입력존의수) 'IIf(dr냉방.개별기기적용 = "0", 1, TOSG(Dr존.입력존의수))   '//20130818
                If Dr존.열생산냉방생산기기 = dr냉방.code And (Dr존.냉난방방식 = "냉난방" OrElse Dr존.냉난방방식 = "냉방") Then
                    A_Q_c_b_i += Result.E분석(i_count_month).냉방에너지요구량열(Dr존.code) / system_count '2013.08.18 수정 ' CSng(Drow분석(0).냉방요구량열) ' Sheets("" & i_count_month & "").Cells(10, 7 + i_count_zone)
                End If
                If Dr존.공조냉방생산기기 = dr냉방.code And Dr존.냉난방공조 = "냉난방" OrElse Dr존.냉난방공조 = "냉방" OrElse ((Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예") Then
                    If (Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예" Then '// 2010.11.19 추가
                        A_Q_c_star_b_i += TOSG(Drow분석(0).냉방요구량공조) / system_count '2013.08.18 수정  '//2010.11.19 추가
                    Else
                        A_Q_c_star_b_i += Result.E분석(i_count_month).공조에너지요구량냉방(Dr존.code) / system_count '2013.08.1 수정 ' CSng(Drow분석(0).공조요구량냉방) ' Sheets("" & i_count_month & "").Cells(21, 7 + i_count_zone)
                    End If
                End If
                '//프로필시간
                Dim Dr프로필 As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & Dr존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)
                If i_count_month = 0 Then
                    d_op_mth = 0
                Else
                    d_op_mth = CInt(Dr프로필("day" & Format(i_count_month, "00")))
                End If
                If d_op_max_mth < d_op_mth Then d_op_max_mth = d_op_mth
                If t_h_max < TOSG(Dr프로필.일일운전시간) * d_op_mth Then
                    t_h_max = CInt(TOSG(Dr프로필.일일운전시간) * d_op_mth)
                End If

                If d_op_mth > a_d_op_max_mth Then a_d_op_max_mth = d_op_mth
                If t_h_max > a_t_h_max Then a_t_h_max = t_h_max
            Next
        Next
        pLog.Add(String.Format("헤더적용부분후의 결과값 냉방용량합={0},a_d_op_max_mth={1},a_t_h_max={2}", 냉방용량합, a_d_op_max_mth, a_t_h_max))


        For Each dr냉방 As DS.tbl_nangbangkikiRow In DSET.tbl_nangbangkiki.Select("code<>'0'", "code")
            Dim DrZRows() As DS.tbl_zoneRow = DSET.tbl_zone.Select("(공조냉방생산기기 = '" & dr냉방.code & "' and 냉난방공조 <> '기능없음' and (외기부하처리여부 = '예' or 냉난방공조 = '냉난방' or 냉난방공조 = '냉방') ) or (열생산냉방생산기기='" & dr냉방.code & "'  and 냉난방방식 <> '난방' and 냉난방방식 <> '기능없음') and code <> '0'", "code")
            If DrZRows.Length > 0 Then    '//존재하는것만 합친다. 150112 - arin

                '//
                pLog.Add(String.Format("사용된냉방기기로직실행준비 Code={0}", dr냉방.code))

                '//
                Dim 비율 As Decimal
                If 냉방용량합 = 0 Then
                    비율 = 1
                Else
                    비율 = dr냉방.냉동기용량 / 냉방용량합
                End If

                '//
                If dr냉방.개별기기적용 = "1" Then
                    Calc_개별기기적용시(dr냉방, Mon, 비율, i_count_month, theta_e)
                Else
                    Calc_개별기기미적용시(dr냉방, Mon, 비율, i_count_month, theta_e)
                End If

            End If

        Next '1


        '//계산결과 시트의 각 월에해당되는 곳에 데이터를 기록한다.

        Result.E소요량(i_count_month).냉방 = Q_c_f
        Result.E소요량(i_count_month).냉방보조 = Q_c_aux

        use_Elec = use_Elec + Q_c_aux

        Result.일차E소요량(i_count_month).냉방등유 = use_Oil
        Result.일차E소요량(i_count_month).냉방LNG = use_LNG
        Result.일차E소요량(i_count_month).냉방LPG = use_LPG
        Result.일차E소요량(i_count_month).냉방지역난방열 = use_DH
        '--------------------------------------------------------------------------------------------------2010.02.22 수정
        Result.일차E소요량(i_count_month).냉방지역냉방열 = use_DC
        '--------------------------------------------------------------------------------------------------2010.02.22 수정
        Result.일차E소요량(i_count_month).냉방전력 = use_Elec

        pLog.Add(String.Format("냉방시스템결과 냉방={0},냉방보조={1},등유={2},LNG={3},LPG={4},지역난방열={5},지역냉방열={6},전력={7}", Q_c_f, Q_c_aux, use_Oil, use_LNG, use_LPG, use_DH, use_DC, use_Elec))

    End Sub

    Dim DSET As DS
    Dim DSETR As DSR
    Dim Result As CResult
    Public Sub New(ByRef pds As DS, ByRef pdsr As DSR, ByRef presult As CResult)
        DSET = pds
        DSETR = pdsr
        Result = presult
    End Sub

    Private Sub Calc_개별기기적용시(ByRef dr냉방 As DS.tbl_nangbangkikiRow, Mon As String, 비율 As Single, i_count_month As Integer, theta_e As Decimal)

        pLog.Add(String.Format(">>Calc_개별기기적용시 냉방기={0},Mon={1},비율={2},월={3},theta_e={4}", dr냉방.code, Mon, 비율, i_count_month, theta_e))

        ''//아 냉방기기를 사용한 존의수(입력존의수적용카운트)         
        'Dim DRzz() As DS.tbl_zoneRow = DSET1.tbl_zone.Select("열생산냉방생산기기='" & dr냉방("code").ToString & "' or 공조냉방생산기기='" & dr냉방("code").ToString & "'") '//2010.12.02 수정
        'Dim loopcnt As Integer = 0
        'For Each drowz As DS.tbl_zoneRow In DRzz
        '    Dim 입력존수문자 As Integer = drowz.입력존의수
        '    If IsNumeric(입력존수문자) = False Then 입력존수문자 = "1"
        '    loopcnt += CInt(입력존수문자)
        'Next

        '//이 냉방기가가 존에서 사용되었는지확인한다.

        Dim dr존데이터() As DS.tbl_zoneRow = DSET.tbl_zone.Select("(공조냉방생산기기 = '" & dr냉방.code & "' and 냉난방공조 <> '기능없음' and (외기부하처리여부 = '예' or 냉난방공조 = '냉난방' or 냉난방공조 = '냉방') ) or (열생산냉방생산기기='" & dr냉방.code & "'  and 냉난방방식 <> '난방' and 냉난방방식 <> '기능없음') and code <> '0'", "code")

        If dr존데이터.Length > 0 Then
            Q_c_b = 0
            Q_c_star_b = 0
            t_h_max = 0
            Q_c_f_elektr = 0
            Q_c_outg_therm = 0
            Q_c_g = 0
            Q_c_f_R_elektr = 0
            system_count = 0
            '==================================2014.07.01 수정
            d_op_max_mth = 0
            '==================================2014.07.01 수정

        End If

        For Each Dr존 As DS.tbl_zoneRow In dr존데이터 '//3개  (5,1,1)

            Dim Drow분석() As DSR.월별에너지분석Row = CType(DSETR.월별에너지분석.Select("월='" & Mon & "' and 존='" & Dr존.code & "'"), DSR.월별에너지분석Row())
            system_count = TOSG(Dr존.입력존의수) 'IIf(dr냉방.개별기기적용 = "0", 1, TOSG(Dr존.입력존의수))   '//20130818
            ' 존데이터를가져올떄 해당 냉방기기에서 사용한 존만 가져왔따.
            ' If Dr존.열생산냉방생산기기 <> "" Then ' Worksheets("입력존").Range("입력냉방생산기기1").Offset(0, i_count_zone - 1) <> "" Then
            ' If Dr존.열생산냉방생산기기 = dr냉방.code Then ' Worksheets("입력존").Range("입력냉방생산기기1").Offset(0, i_count_zone - 1) = Worksheets("냉방기기").Range("냉방생산기기1").Offset(0, i_count_chiller - 1) Then


            '==================================================2014.07.01 수정

            'If dr냉방.헤더적용 Then
            '    Q_c_b_i = A_Q_c_b_i
            '    Q_c_b_i *= 비율 '//130818
            '    Q_c_b = Q_c_b_i '//Q_c_b + Q_c_b_i

            '    Q_c_star_b_i = A_Q_c_star_b_i
            '    Q_c_star_b_i *= 비율 '//130818
            '    Q_c_star_b = Q_c_star_b_i
            'Else
            If Dr존.열생산냉방생산기기 = dr냉방.code And (Dr존.냉난방방식 = "냉난방" OrElse Dr존.냉난방방식 = "냉방") Then
                Q_c_b_i = Result.E분석(i_count_month).냉방에너지요구량열(Dr존.code) / system_count '2013.08.18 수정 ' CSng(Drow분석(0).냉방요구량열) ' Sheets("" & i_count_month & "").Cells(10, 7 + i_count_zone)
                Q_c_b = Q_c_b_i
            End If
            If Dr존.공조냉방생산기기 = dr냉방.code And Dr존.냉난방공조 = "냉난방" OrElse Dr존.냉난방공조 = "냉방" OrElse ((Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예") Then
                If (Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예" Then '// 2010.11.19 추가
                    Q_c_star_b_i = TOSG(Drow분석(0).냉방요구량공조) / system_count '2013.08.18 수정  '//2010.11.19 추가
                Else
                    Q_c_star_b_i = Result.E분석(i_count_month).공조에너지요구량냉방(Dr존.code) / system_count '2013.08.18 수정 ' CSng(Drow분석(0).공조요구량냉방) ' Sheets("" & i_count_month & "").Cells(21, 7 + i_count_zone)
                End If
                Q_c_star_b = Q_c_star_b_i
            End If
            'End If


            '===================================================================================2010.2.21 수정
            ' Dim Drow최대() As DSR.최대냉난방부하Row = CType(DSETR.최대냉난방부하.Select("zone='" & Dr존.code & "'"), DSR.최대냉난방부하Row())


            '==================================================2014.07.01 수정
            'If dr냉방.헤더적용 Then
            '    '//헤더로 묶인 냉방기기의 존들에서 
            '    d_op_max_mth = a_d_op_max_mth
            '    t_h_max = a_t_h_max
            'Else
            Dim Dr프로필 As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & Dr존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)
            If i_count_month = 0 Then
                d_op_mth = 0
            Else
                d_op_mth = CInt(Dr프로필("day" & Format(i_count_month, "00")))
            End If
            If d_op_max_mth < d_op_mth Then d_op_max_mth = d_op_mth
            If t_h_max < TOSG(Dr프로필.일일운전시간) * d_op_mth Then t_h_max = CInt(TOSG(Dr프로필.일일운전시간) * d_op_mth)
            'End If






            '===================================================================================2010.2.21 수정
            ' End If
            ' End If


            '//system = 7

            'Q_vh_b = Sheets("" & i_count_month & "").Cells(19, 7 + i_count_zone)
            'Q_vc_b = Sheets("" & i_count_month & "").Cells(21, 7 + i_count_zone)
            'Q_vm_b = Sheets("" & i_count_month & "").Cells(23, 7 + i_count_zone)


            '==========================================================================================================================================
            ' 가열유닛에 대한 사용에너지(3차 에너지)
            ' 외부 공조덕트가 없어서 Q_vh_d 는 0으로 적용

            'Q_dot_V_H_max = V_dot_star_rho_L(c_p_L * (theta_ZUL_wi - theta_AUL_wi) - Delta_h_WRG) '(3.2.5-58)
            'Q_dot_V_H_max = V_dot_star * rho_L(h_ZUL_wi - h_AUL_wi - Delta_h_WRG) '(3.2.5-57)
            'b_VH_a = sigma1_12(b_VH_month) '(3.2.8-7)
            'b_VH_mth = Q_vh_b / Q_dot_V_H_max '(3.2.8-6)
            't_H_r = t_H_r_14_12h + (t_H_r_22_12h - t_H_r_14_12h) * (theta_V_mech - 14) / 8 '(3-B.1) theta_V_mech은 (3-C.1)
            't_H_star_op_mth = t_H_r * b_VH_mth / b_VH_a '(3.2.8-5)
            'Q_vh_d = f_vh_d * A_K_A * t_H_star_opo_mth '(3.2.8-10) f_vh_d=16W/m

            'Q_vh_ce = (1 - eta_vh_ce) * Q_vh_b '(3.2.8-9) eta_vh_ce 는 1로 Q_vh_ce 는 0이 됨
            'Q_h_star_b = Q_vh_b 'Q_h_star_b = Q_vh_b + Q_vh_ce + Q_vh_d '(3.2.8-2)
            '==========================================================================================================================================



            '==========================================================================================================================================
            ' 냉각 유닛에 대한 사용 에너지(3차 에너지)
            ' 외부 공조덕트가 없어서 Q_vc_d 는 0으로 적용

            'Q_dot_V_C_max = V_dot_star * rho_L(h_AUL_so - h_ZUL_so - Delta_h_WRG) '(3.2.5-62)
            'b_VC_a = sigma1_12(b_VC_month) '(3.2.8-13)
            'b_VC_mth = Q_vc_b / Q_dot_V_C_max '(3.2.8-12)
            't_C_r = (t_C_r_14_12h + (t_C_r_22_12h - t_C_r_14_12h) * (theta_V_mech - 14) / 8) * f_h_C '(3-B.2) theta_V_mech은 (3-C.1)
            't_C_star_op_mth = t_C_r * b_VC_mth / b_VC_a '(3.2.8-11)
            'Q_vc_d = f_vc_d * A_K_A * t_C_star_opo_mth '(3.2.8-10) f_vh_d=9W/m
            'Q_vc_ce = (1 - eta_vc_ce) * Q_vc_b '(3.2.8-9) eta_vc_ce 는 1로 Q_vc_ce 는 0이 됨

            'Q_c_star_b = Q_vc_b 'Q_c_star_b = Q_vc_b + Q_vc_ce + Q_vc_d '(3.2.8-8)

            '==========================================================================================================================================


            '가습
            'Q_m_star_b = Q_vm_b '(3.2.8-14)


            ' 실-냉방 냉열 공급

            'Q_c_b = Sheets("" & i_count_month & "").Cells(7, 7 + i_count_zone)

            Q_c_d = (1 - eta_c_d) * Q_c_b '(3.2.8-21) eta_c_d는 (Tab.7-8)
            Q_c_ce = ((1 - eta_c_ce) + (1 - eta_c_ce_sens)) * Q_c_b '(3.2.5-20) eta_c_ce는(Tab.7-8), eta_c_ce_sens는 (Tab.7-7)

            Q_c_outg = Q_c_b + Q_c_ce + Q_c_d + Q_c_s '(3.2.8-19)



            '==========================================================================================================================================
            ' 실-냉방 2차 공기 송풍기의 전기에너지 요구량
            ' 추후 세부 변수 검토

            'beta_c_i = beat_c_we = Q_c_b_we / (Q_c_max_res * t_c_op_we) '(2-D.7)
            'beta_c_i = beta_c_nutz = Q_c_b_nutz / (Q_c_max_res * t_c_op_nutz)
            't_c_i = t_mth_nutz = d_nutz * t_c_op_nutz '(2-D.8) t_c_i=t_mth_we=d_we*t_c_op_we
            't_c_i = t_mth_i * beta_c_i / beta_c_grenz '(2-D.6)
            't_c_op = t_c_NR + t_c_we '(2-D.5)
            'Q_c_outg = Q_c_b + Q_c_ce + Q_c_d + Q_c_s '(3.2.8-19)
            'Q_c_ce_aux = f_c_ce_aux * Q_c_outg * t_c_op / 1000 '(3.2.8-23) f_c_ce_aux 는 (Tab.3.93)
            Q_c_ce_aux = f_c_ce_aux * Q_c_outg * t_h_max / 1000


            '==========================================================================================================================================




            '공조-냉방 냉열 공급

            Q_c_star_d = (1 - eta_c_star_d) * Q_c_star_b '(3.2.8-18) eta_c_star_d는 (Tab.3.91)
            Q_c_star_ce = ((1 - eta_c_star_ce) + (1 - eta_c_star_ce_sens)) * Q_c_star_b '(3.2.8-16) eta_c_star_ce는 (Tab.3.91), eta_c_star_ce_sens는 (Tab.3.91)

            Q_c_star_outg = Q_c_star_b + Q_c_star_ce + Q_c_star_d + Q_c_star_s '(3.2.8-15)
            Q_z_star_outg_l = Q_c_star_outg


            ' 공조기기 가습에 필요한 생산기의 이용열 교부


            'Q_m_star_d = 0
            'Q_m_star_ce = 0
            'Q_m_star_b = Q_vm_b '(3.2.8-14)
            'Q_m_star_outg = Q_m_star_b 'Q_m_star_outg = Q_m_star_b + Q_m_star_ce + Q_m_star_d '(3.2.8-24)


            Q_c_outg_total = Q_c_outg + Q_c_star_outg

            Q_z_outg_l = Q_c_outg_total



            '==================================================================================================================================
            '==================================================================================================================================
            '지열시스템

            Dim CRenew As New CRenewable(DSET, Result)
            If dr냉방.신재생연결여부 = "시스템연결" AndAlso dr냉방.연결된시스템 <> "0" Then ' 시스템연결" Then
                Dim Dr신재생 As DS.tbl_newRow = CType(DSET.tbl_new.Select("code='" & dr냉방.연결된시스템 & "' and code <> '0'")(0), DS.tbl_newRow)
                '//연결되었을시에는 
                Select Case Dr신재생.기기종류.Trim
                    Case "태양열" '//태양열
                    Case "태양광" '//태양광
                    Case "지열" '//지열
                        Select Case Dr신재생.가동연료.Trim
                            Case "전기" '전기"
                                CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                                Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                                Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                                use_Elec = use_Elec + Q_c_f_hp + Q_c_g_hp_aux
                            Case "천연가스" '천연가스"
                                CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                                Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                                Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                                use_LNG = use_LNG + Q_c_f_hp
                                use_Elec = use_Elec + Q_c_g_hp_aux
                            Case "액화가스" '액화가스"
                                CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                                Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                                Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                                use_LPG = use_LPG + Q_c_f_hp
                                use_Elec = use_Elec + Q_c_g_hp_aux
                        End Select
                    Case "열병합" '//열병합
                End Select
            End If

            '==================================================================================================================================
            '==================================================================================================================================

            EER = TOSG(dr냉방.열성능비) * age ' Dr냉방.열성능비
            Q_dot_c_outg = TOSG(dr냉방.냉동기용량) ' dr냉방.냉동기용량

            If t_h_max = 0 Then '=============================================2014.03.07 추가
                k_n = 0
            Else
                k_n = Q_c_outg_total / (Q_dot_c_outg * t_h_max)
            End If             '=============================================2014.03.07 추가



            If k_n > 1 Then k_n = 1

            k_n_index = 100 ' 조건에 없는 압축방식에서 에러 발생 유도함

            Select Case dr냉방.냉동기방식.Trim 'Dr냉방.냉동기방식
                Case "압축식", "압축식(LNG)" '압축식"
                    T_W_1_i = TOSG(dr냉방.냉각탑입구온도) ' Dr냉방.냉각탑입구온도
                    Select Case dr냉방.냉동기종류.Trim ' Dr냉방.냉동기종류
                        Case "수냉식" '수냉식"
                            Select Case dr냉방.냉동기압축방식.Trim ' Dr냉방.냉동기압축방식
                                Case "왕복동/스크롤 압축기" '왕복동/스크롤압축기"
                                    Select Case dr냉방.압축기제어방식.Trim 'Dr냉방.압축기제어방식
                                        Case "on/off제어"
                                            k_n_index = 7
                                            f_2_av = 1
                                        Case "다단제어" '다단제어"
                                            k_n_index = 8
                                            Select Case dr냉방.증발식건식냉각기.Trim ' Dr냉방.증발식건식냉각기
                                                Case "증발식" '증발식"
                                                    f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                                Case "건식" '건식"
                                                    f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                                Case Else
                                                    MsgBox("22")
                                            End Select
                                        Case "실린더off"
                                            k_n_index = 9
                                            Select Case dr냉방.증발식건식냉각기.Trim
                                                Case "증발식" '증발식"
                                                    f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                                Case "건식" '건식"
                                                    f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                                Case Else
                                                    MsgBox("21")
                                            End Select
                                        Case "바이패스제어" '바이패스제어"
                                            k_n_index = 10
                                            f_2_av = 1
                                        Case Else
                                            MsgBox("19")
                                    End Select
                                Case "스크류압축기" '스크류압축기"
                                    k_n_index = 11
                                    Select Case dr냉방.증발식건식냉각기.Trim
                                        Case "증발식" '증발식"
                                            f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                        Case "건식" '건식"
                                            f_2_av = TOSG(3.1851 - 0.0486 * T_W_1_i)
                                        Case Else
                                            MsgBox("18")
                                    End Select
                                Case "터보압축기" '터보압축기"
                                    k_n_index = 12
                                    Select Case dr냉방.증발식건식냉각기.Trim
                                        Case "증발식" '증발식"
                                            f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                        Case "건식" '건식"
                                            f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                        Case Else
                                            MsgBox("16")
                                    End Select
                                Case Else
                                    MsgBox("17")
                            End Select

                        Case "공냉식" '공냉식"
                            Select Case dr냉방.냉동기압축방식.Trim
                                Case "왕복동/스크롤 압축기" '왕복동/스크롤압축기"
                                    Select Case dr냉방.압축기제어방식.Trim
                                        Case "on/off제어"
                                            k_n_index = 0
                                            f_2_av = 1
                                        Case "다단제어" '다단제어"
                                            k_n_index = 1
                                            f_2_av = 1
                                        Case Else
                                            MsgBox("15")
                                    End Select
                                Case "스크류압축기" '스크류압축기"
                                    k_n_index = 2
                                    f_2_av = 1
                                Case Else
                                    MsgBox("14")
                            End Select

                        Case "실내공조시스템" '실내공조시스템"
                            Select Case dr냉방.냉동기설비시스템.Trim ' Dr냉방.냉동기설비시스템
                                Case "콤팩트형시스템" '콤팩트형시스템"
                                    k_n_index = 3
                                    f_2_av = 1
                                Case "실내외분리시스템" '실내외분리시스템"
                                    Select Case dr냉방.제어방식.Trim.ToLower '냉동기설비시스템의제어방식 Dr냉방.제어방식
                                        Case "on/off제어"
                                            k_n_index = 3
                                            f_2_av = 1
                                        Case "회전수제어" '회전수제어"
                                            k_n_index = 5
                                            f_2_av = 1
                                        Case Else
                                            MsgBox(dr냉방.제어방식.Trim)
                                    End Select
                                Case "멀티분리시스템" '멀티분리시스템"
                                    Select Case dr냉방.제어방식.Trim
                                        Case "on/off제어"
                                            k_n_index = 4
                                            f_2_av = 1
                                        Case "회전수제어" '회전수제어"
                                            k_n_index = 6
                                            f_2_av = 1
                                        Case Else
                                            MsgBox("11")
                                    End Select
                                Case Else
                                    MsgBox("13")
                            End Select
                        Case Else
                            MsgBox("30")
                    End Select
                    '//이부분정확히 살펴보아야할듯 
                    If k_n = 0 Then k_n = 0.001 ' 부분부하율이 0일 경우 부분부하를 0에서 0.1구간으로 설정
                    'Dim Drow부분부하() As DS.tbl_buhaRow = DSET.tbl_buha.Rows(k_n_index) '.Select("code='" & Format(9 - Int((1 - k_n) * 10), "00") & "'")

                    If k_n_index >= 100 Then
                        LogSB.AppendLine("냉방기기(" & dr냉방.설명 & ")의 냉동기방식(" & dr냉방.냉동기방식.Trim & ")에따른 종류(" & dr냉방.냉동기종류.Trim & ")를 확인할 수 없습니다")
                        Exit For 'Return
                    Else
                        f_1_av_up = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 2)))
                        If k_n < 0.1 Then
                            f_1_av_dn = f_1_av_up
                        Else
                            f_1_av_dn = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 1)))
                        End If
                        f_1_av = f_1_av_up - (f_1_av_up - f_1_av_dn) * (1 - (k_n * 10 - Int(k_n * 10)))

                        'f_1_av = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 2))) ' Worksheets("부분부하율").Range("냉동기부분부하율1").Offset(k_n_index, 9 - Int((1 - k_n) * 10))
                    End If

                    PLV_av = f_1_av * f_2_av

                    ' If i_count_month = 8 Then
                    ' Dim data As String = vbCrLf + "적용시 " + i_count_month.ToString() + "월  ply_av=" + PLV_av.ToString()
                    ' My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\kn.txt", data, True, System.Text.Encoding.Default)
                    ' End If

                    If PLV_av = 0 Then  '=======================================================================2014.03.07 추가
                        Q_c_f_elektr = 0
                        Q_c_outg_therm = 0
                    Else

                        If dr냉방.냉동기방식 = "압축식" Then
                            Q_c_f_elektr = Q_c_outg_total / (EER * PLV_av)
                            '======================================================================= 2010.10.5 추가
                        ElseIf dr냉방.냉동기방식 = "압축식(LNG)" Then
                            Q_c_outg_therm = Q_c_outg_total / (EER * PLV_av)
                            use_LNG = use_LNG + Q_c_outg_therm
                            '======================================================================= 2010.10.5 추가
                        End If
                    End If                '=======================================================================2014.03.07 추가



                    If (dr냉방.냉동기방식 = "압축식" Or dr냉방.냉동기방식 = "압축식(LNG)") And dr냉방.냉동기종류 = "수냉식" Then 'If Dr냉방.냉동기방식 = "압축식" And Dr냉방.냉동기종류 = "수냉식" Then
                        Q_dot_R_outg = Q_dot_c_outg * (1 + 1 / EER)
                        Select Case dr냉방.증발식건식냉각기.Trim
                            Case "증발식" '증발식"
                                l_min_i = TOSG(1.2103 - 0.0162 * theta_e) '원래는 습구온도로 입력요망 우선 외기건구온도로 입력 추후 수정
                                'f_R_av = (Log(1 - 0.5 / 0.8) * l_min_i / (Log(1 - 0.5 / 0.8) * 0.87)) ^ 2 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                                If Q_dot_c_outg = 0 Or t_h_max = 0 Then '===================================================2014.03.07 추가
                                    f_R_av = 0
                                Else
                                    f_R_av = Q_c_outg_total * 4 / (Q_dot_c_outg * t_h_max) ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                                End If '===================================================2014.03.07 추가

                                If f_R_av > 1 Then f_R_av = 1 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산하고 최대가동시간 이하로 계산 추후 수정
                                Select Case dr냉방.증발식냉각기.Trim 'Dr냉방.증발식냉각기
                                    Case "폐쇄형" '폐쇄형"
                                        Select Case dr냉방.보조방음기유무.Trim 'Dr냉방.보조방음기유무
                                            Case "아니오" '아니오"
                                                q_R_elektr = 0.033
                                            Case "예" '예"
                                                q_R_elektr = 0.04
                                        End Select
                                    Case "개방형" '개방형"
                                        Select Case dr냉방.보조방음기유무.Trim
                                            Case "아니오" '아니오"
                                                q_R_elektr = 0.018
                                            Case "예" '예"
                                                q_R_elektr = 0.021
                                        End Select
                                End Select
                            Case "건식" '건식"
                                f_R_av = 1 '우선 1로 적용 추후 검토
                                q_R_elektr = 0.045
                        End Select
                        Q_c_f_R_elektr = Q_dot_R_outg * q_R_elektr * f_R_av * t_h_max
                    Else
                        Q_c_f_R_elektr = 0
                    End If


                Case "흡수식" '흡수식"
                    Q_dot_R_outg = Q_dot_c_outg * (1 + 1 / EER)
                    T_W_1_i = TOSG(dr냉방.냉각탑입구온도)
                    Select Case dr냉방.증발식건식냉각기.Trim
                        Case "증발식" '증발식"
                            l_min_i = TOSG(1.2103 - 0.0162 * theta_e) '원래는 습구온도로 입력요망 우선 외기건구온도로 입력 추후 수정
                            'f_R_av = (Log(1 - 0.5 / 0.8) * l_min_i / (Log(1 - 0.5 / 0.8) * 0.87)) ^ 2 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정


                            If Q_dot_c_outg = 0 Or t_h_max = 0 Then '===================================================2014.03.07 추가
                                f_R_av = 0
                            Else
                                f_R_av = Q_c_outg_total * 4 / (Q_dot_c_outg * t_h_max) ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                            End If '===================================================2014.03.07 추가


                            If f_R_av > 1 Then f_R_av = 1 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산하고 최대가동시간 이하로 계산 추후 수정
                            Select Case dr냉방.증발식냉각기.Trim
                                Case "폐쇄형"
                                    Select Case dr냉방.보조방음기유무.Trim
                                        Case "아니오"
                                            q_R_elektr = 0.033
                                        Case "예"
                                            q_R_elektr = 0.04
                                    End Select
                                Case "개방형"
                                    Select Case dr냉방.보조방음기유무.Trim
                                        Case "아니오"
                                            q_R_elektr = 0.018
                                        Case "예"
                                            q_R_elektr = 0.021
                                    End Select
                            End Select
                        Case "건식" '건식"
                            f_R_av = 1 '우선 1로 적용 추후 검토
                            q_R_elektr = 0.045
                    End Select
                    Q_c_f_R_elektr = Q_dot_R_outg * q_R_elektr * f_R_av * t_h_max

                    Select Case dr냉방.증발식건식냉각기.Trim
                        Case "증발식"
                            f_2_av = TOSG(1.7174 - 0.0217 * T_W_1_i)
                        Case "건식"
                            f_2_av = TOSG(2.3235 - 0.0294 * T_W_1_i)
                        Case Else
                            'MsgBox("증발식건식냉각기를 확인할 수 없습니다" & vbCrLf & "Calc_CoolingSystem 429번줄 Case else 를 입력하세요", MsgBoxStyle.Critical, dr냉방.증발식건식냉각기)

                    End Select

                    '//13번째줄
                    If k_n = 0 Then k_n = 0.01 ' 부분부하율이 0일 경우 부분부하를 0에서 0.1구간으로 설정
                    f_1_av_up = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 2)))
                    If k_n < 0.1 Then
                        f_1_av_dn = f_1_av_up
                    Else
                        f_1_av_dn = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 1)))
                    End If
                    f_1_av = f_1_av_up - (f_1_av_up - f_1_av_dn) * (1 - (k_n * 10 - Int(k_n * 10)))
                    'f_1_av = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 2))) 'Worksheets("부분부하율").Range("냉동기부분부하율1").Offset(13, 9 - Int((1 - k_n) * 10))
                    PLV_av = f_1_av * f_2_av

                    If PLV_av = 0 Then '===========================================2014.03.07 추가
                        Q_c_outg_therm = 0
                    Else
                        Q_c_outg_therm = Q_c_outg_total / (EER * PLV_av)
                    End If '===========================================2014.03.07 추가



                    ': 흡수식 냉동기에서 사용되는 보일러의 생산손실에너지 계산
                    If dr냉방.열생산연결방식.ToString = "외부연결" Then '==============================2010.04.02 if문 추가


                        '//냉방의 온수열생산기기로 지정된 난방기기만을 취한다 10.02.23 최적화중변경
                        For Each Dr난방 As DS.tbl_nanbangkikiRow In DSET.tbl_nanbangkiki.Select("code = '" & dr냉방.온수열생산기기 & "' and code <> '0'", "code")
                            'If Dr난방.code = dr냉방.온수열생산기기 Then ' Dr냉방.온수열생산기기 Then

                            theta_VA = TOSG(Dr난방.급수온도) ' Worksheets("난방기기").Range("난방기기급수온도1").Offset(0, i_count_c_d - 1)
                            theta_RA = TOSG(Dr난방.환수온도) ' Worksheets("난방기기").Range("난방기기환수온도1").Offset(0, i_count_c_d - 1)

                            theta_HK_m_beta_h_d = TOSG(0.5 * (theta_VA + theta_RA))

                            '----------------------------------------------------------------------------------------------------------------------------------
                            '----------------------------------------------------------------------------------------------------------------------------------

                            '신재생 및 열병합 시스템
                            Dim CNew As New CRenewable(DSET, Result)
                            If Dr난방.신재생연결여부 = "시스템연결" AndAlso Dr난방.연결된시스템 <> "0" Then ' Worksheets("난방기기").Range("신재생난방연결1").Offset(0, i_count_c_d - 1) = "시스템연결" Then
                                Dim Dr신재생 As DS.tbl_newRow = CType(DSET.tbl_new.Select("code='" & Dr난방.연결된시스템 & "' and code <> '0'")(0), DS.tbl_newRow)
                                Select Case Dr신재생.기기종류.Trim
                                    Case "태양열" '//태양열
                                        '========================================================================================2010.04.02 추가
                                        If Q_c_outg_therm > 0 Then
                                            Calc.Renewable.Calc_ThermalSolarSystem_EN(system_type, Dr신재생.code, i_count_month, d_op_max_mth, Q_h_outg_i, Q_c_outg_therm, Q_W_sol_out_m, Q_H_sol_out_m, W_sol_aux_m)
                                            Q_c_outg_therm = Q_c_outg_therm - Q_W_sol_out_m
                                            Q_c_aux = Q_c_aux + W_sol_aux_m
                                        End If
                                        '========================================================================================2010.04.02 추가
                                    Case "태양광" '//태양광
                                    Case "지열" '//지열                                           
                                    Case "열병합" '//열병합
                                        If Q_c_outg_therm > 0 Then '===========================2010.04.02  And Q_c_outg_therm > 0 추가
                                            Select Case Dr신재생.가동연료.Trim
                                                Case "난방유" '난방유"
                                                    CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                    Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                    use_Oil = use_Oil + Q_c_f_chp

                                                Case "천연가스" '천연가스"
                                                    CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                    Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                    use_LNG = use_LNG + Q_c_f_chp

                                                Case "액화가스" '액화가스"
                                                    CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                    Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                    use_LPG = use_LPG + Q_c_f_chp

                                            End Select
                                        End If

                                End Select
                            End If


                            '----------------------------------------------------------------------------------------------------------------------------------
                            '----------------------------------------------------------------------------------------------------------------------------------


                            If Dr난방.열생산기기방식 = "보일러" Then ' Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1) = "보일러" Then

                                Q_dot_N = TOSG(Dr난방.정격보일러효율) * age_heating ' Worksheets("난방기기").Range("난방기기정격출력1").Offset(0, i_count_c_d - 1)
                                If t_h_max = 0 Then '====================================2014.03.07 추가
                                    Q_dot_d_in = 0
                                Else
                                    Q_dot_d_in = Q_c_outg_therm / t_h_max
                                End If   '====================================2014.03.07 추가



                                Select Case Dr난방.운전방식.Trim ' Worksheets("난방기기").Range("난방기기운전방식1").Offset(0, i_count_c_d - 1)
                                    Case "단독가동" '단독가동"
                                        beta_h = Q_dot_d_in / Q_dot_N '(3.2.7-64) : 단일보일러 시설
                                    Case "동시가동" ' 동시가동"
                                        beta_h = Q_dot_d_in / (Q_dot_N * TOSG(Dr난방.보일러대수)) ' Worksheets("난방기기").Range("난방기기운전방식1").Offset(1, i_count_c_d - 1)) '(3.2.7-64) : 다수보일러 동시가동
                                    Case "순차가동" '순차가동"
                                        For i_count_beta = 1 To CInt(TOSG(Dr난방.보일러대수))
                                            If Q_dot_d_in <= (Q_dot_N * i_count_beta) Then
                                                beta_h = (Q_dot_d_in - Q_dot_N * (i_count_beta - 1)) / Q_dot_N * i_count_beta '다수보일러 대수제어
                                                n_beta = i_count_beta - 1
                                                Exit For
                                            End If
                                        Next
                                End Select


                                eta_k_100 = TOSG(Dr난방.정격보일러효율) * age_heating / 100 'Worksheets("난방기기").Range("난방기기정격효율1").Offset(0, i_count_c_d - 1) / 100
                                eta_k_pl = eta_k_100
                                f = -0.4
                                Select Case Dr난방.보일러방식.Trim 'Worksheets("난방기기").Range("보일러방식1").Offset(0, i_count_c_d - 1)
                                    Case "가스보일러" '가스보일러"
                                        e = 8.5
                                        f = -0.4
                                    Case "기름보일러" '기름보일러"
                                        e = 8.5
                                        f = -0.4
                                    Case "저온가스보일러" '저온가스보일러"
                                        e = 4.5
                                        f = -0.4
                                    Case "저온기름보일러" '저온기름보일러"
                                        e = 4.25
                                    Case "콘덴싱보일러" '콘덴싱보일러"
                                        e = 4
                                End Select

                                q_B_70 = TOSG((e * (Q_dot_N ^ f)) / 100)
                                q_B_theta = q_B_70 '원래는 =q_B_70 * (theta_HK_m_beta_h_g - theta_i) / (70 - 20) 이지만 q_B_theta 와 q_B_70 이 같은 것으로 적용 추후검토

                                'Select Case Worksheets("난방기기").Range("난방기기사용연료1").Offset(0, i_count_c_d - 1)
                                'Case "난방유"
                                'f_Hs_Hi = 1.06
                                'Case "천연가스"
                                'f_Hs_Hi = 1.11
                                'Case "액화가스"
                                'f_Hs_Hi = 1.09
                                'Case "석탄"
                                'f_Hs_Hi = 1.04
                                'Case "갈탄"
                                'f_Hs_Hi = 1.07
                                'Case "나무"
                                'f_Hs_Hi = 1.08
                                'End Select

                                f_Hs_Hi = 1 ' 국내는 총발열량을 기준으로 입력함으로 우선 1로 설정, 추후 검토

                                Q_dot_B_h = q_B_theta * (Q_dot_N / eta_k_100) * f_Hs_Hi '(3.2.7-71)

                                Q_V_g_100 = (f_Hs_Hi - eta_k_100) / eta_k_100 * Q_dot_N
                                Q_V_g_pl = (f_Hs_Hi - eta_k_pl) / eta_k_pl * beta_k_pl * Q_dot_N

                                '------------------------------------------------------------------------------------------------------

                                If beta_h > beta_k_pl Then
                                    Q_c_g_v_i = ((beta_h - beta_k_pl) / (1 - beta_k_pl) * (Q_V_g_100 - Q_V_g_pl) + Q_V_g_pl)
                                    Q_c_g_v_i = Q_c_g_v_i + ((Q_V_g_100 - Q_V_g_pl) + Q_V_g_pl) * n_beta
                                Else
                                    Q_c_g_v_i = ((beta_h / beta_k_pl) * (Q_V_g_pl - Q_dot_B_h) + Q_dot_B_h)
                                End If


                                Q_c_g = Q_c_g_v_i * t_h_max '  추후 검토

                            Else

                                ':지역난방의 경우 적용 추후 검토
                                Q_c_g = 0

                            End If

                            If Dr난방.열생산기기방식 = "보일러" Then 'Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1) = "보일러" Then
                                Select Case Dr난방.사용연료.Trim ' Worksheets("난방기기").Range("난방기기사용연료1").Offset(0, i_count_c_d - 1)
                                    Case "난방유" '난방유"
                                        use_Oil = use_Oil + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                                    Case "천연가스" '천연가스"
                                        use_LNG = use_LNG + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                                    Case "액화가스" '액화가스"
                                        use_LPG = use_LPG + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                                End Select
                            Else
                                Select Case Dr난방.열생산기기방식.Trim 'Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1)
                                    Case "지역난방" '지역난방"
                                        use_DH = use_DH + Q_c_outg_therm * system_count '========2013.0818 수정

                                    Case "전기보일러" '전기보일러"
                                        use_Elec = use_Elec + Q_c_outg_therm * system_count '========2013.0818 수정

                                End Select

                            End If


                            ' End If


                        Next
                        '=================================================================================================2010.04.02 if문 추가
                    ElseIf dr냉방.열생산연결방식 = "직화식" Then
                        Select Case dr냉방.사용연료.ToString
                            Case "난방유"
                                use_Oil = use_Oil + Q_c_outg_therm * system_count '========2013.0818 수정
                            Case "천연가스"
                                use_LNG = use_LNG + Q_c_outg_therm * system_count '========2013.0818 수정
                            Case "액화가스"
                                use_LPG = use_LPG + Q_c_outg_therm * system_count '========2013.0818 수정
                            Case Else
                                MsgBox("냉동기기(" & dr냉방.설명 & ")가 직화식이나 사용연료가 없습니다.확인바랍니다.", vbOKOnly, "건물 에너지 평가 프로그램(ECO2)")
                        End Select
                    Else
                        MsgBox("냉동기기(" & dr냉방.설명 & ")의 열생산연결방식을 확인바랍니다.", vbOKOnly, "건물 에너지 평가 프로그램(ECO2)")
                    End If

                    '=================================================================================================2010.04.02 if문 추가
                Case "지역냉방" '지역냉방"
                    '--------------------------------------------------------------------------------------------------2010.02.22 수정
                    use_DC = use_DC + Q_c_outg_total * system_count
                    '--------------------------------------------------------------------------------------------------2010.02.22 수정
                    Q_c_outg_therm = Q_c_outg_total

            End Select

            Q_c_f = Q_c_f + (Q_c_f_elektr + Q_c_f_R_elektr + Q_c_outg_therm + Q_c_g) * system_count
            use_Elec = use_Elec + (Q_c_f_elektr + Q_c_f_R_elektr) * system_count


            'If i_count_month = 6 Then
            '    i_count_month = 6
            'End If
            ' 분배에 대한 전기 에너지 소비
            For Each Dr분배 As DS.tbl_bunbaeRow In DSET.tbl_bunbae.Select("냉동기='" & dr냉방.code & "' and code <> '0'", "code")
                'If Dr분배.냉동기 = dr냉방.code Then ' Worksheets("냉방분배시스템").Range("냉동기분배1").Offset(0, i_count_c_d - 1) = Worksheets("냉방기기").Range("냉방생산기기1").Offset(0, i_count_chiller - 1) Then

                Q_dot_z = Q_dot_c_outg * (1 + 1 / EER) '(3.2.8-30)
                Delta_theta_z_cl = TOSG(Dr분배.설정점에서의온도차) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(3, i_count_c_d - 1) 6
                c_cl = TOSG(Dr분배.냉매의비열) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(4, i_count_c_d - 1) 4.18
                rho_cl = TOSG(Dr분배.냉매의밀도) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(5, i_count_c_d - 1)   1000
                V_dot_z = (3600 * Q_dot_z) / (Delta_theta_z_cl * c_cl * rho_cl) '(3.2.8-29)
                L = TOSG(Dr분배.공급범위의길이) ' Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(0, i_count_c_d - 1)
                b = TOSG(Dr분배.공급범위의넓이) 'Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(1, i_count_c_d - 1)
                n_G = TOSG(Dr분배.열층의수) ' Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(2, i_count_c_d - 1)
                h_G = TOSG(Dr분배.층고) 'Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(3, i_count_c_d - 1)
                L_max = 2 * (L + b / 2 + h_G * n_G + 10) '(3.2.8-32)
                R = TOSG(Dr분배.배관의압력손실) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(7, i_count_c_d - 1)  0.3
                z = TOSG(Dr분배.개별저항비율) '("냉방분배시스템").Range("급수온도1").Offset(8, i_count_c_d - 1) 0.4
                Delta_P_WUE = TOSG(Dr분배.생산기기압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(0, i_count_c_d - 1)
                Delta_P_WUV = TOSG(Dr분배.사용기기압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(1, i_count_c_d - 1)
                Delta_P_RV = TOSG(Dr분배.제어밸브압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(2, i_count_c_d - 1)

                Delta_p_z = R * L_max * (1 + z) + Delta_P_WUE + Delta_P_RV + Delta_P_WUV '(3.2.8-31) R(7-Tab.11), Delta_P_WUE, Delta_P_RV, Delta_P_WUV (7-Tab.12)

                P_d_hydr = 1000 * Delta_p_z * V_dot_z / 3600 '(3.2.8-28)

                'f_e = f_dash_e * (1 + (nu_cl ^ 2 / (16 * P_d_hydr)) ^ 0.4) '기존건물 관련
                'f_e = (1.25 + (200 / P_d_hydr) ^ 0.5) * f_Adap * b '(3.2.8-38) '기존건물 관련
                P_Pump = TOSG(Dr분배.펌프동력) 'Worksheets("냉방분배시스템").Range("급수온도1").Offset(9, i_count_c_d - 1)
                'P_Pump = Worksheets("냉방분배시스템").Range("급수온도1").Offset(9, i_count_c_d - 1) << 이거오류인듯 펌프는 8번인덱스여야한다.9번줄에는 아무것도 없다.

                If P_d_hydr = 0 Then '===================================================2014.03.07 추가
                    f_e = 0
                Else
                    f_e = P_Pump / P_d_hydr '원래는 P_hydr '(3.2.8-37)
                End If               '===================================================2014.03.07 추가



                If Dr분배.펌프운전제어유무 = "제어" Then ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(-1, i_count_c_d - 1) = "제어" Then
                    c_p1 = 0.85
                    c_p2 = 0.15
                ElseIf Dr분배.펌프운전제어유무 = "대수제어" Then
                    c_p1 = 0.75
                    c_p2 = 0.25
                Else
                    c_p1 = 0.25
                    c_p2 = 0.75
                End If

                'beta_d_l = beta_dash_ + (1 - beta_dash_d_l) * V_dot_z_min / V_dot_z '(3.2.8-35)
                If Q_z_outg_l <> 0 Then

                    If Q_dot_z = 0 Or t_h_max = 0 Then '===========================================2014.03.07 추가
                        beta_d_l = 0
                        e_d_l = 0
                    Else
                        beta_d_l = Q_z_outg_l / (Q_dot_z * t_h_max) '(3.2.8-34) t_d_l 을 t_h_max으로 사용

                        e_d_l = f_e * (c_p1 + c_p2 / beta_d_l) '(3.2.8-36)

                    End If                             '===========================================2014.03.07 추가


                    W_d_hydr_l = P_d_hydr / 1000 * t_h_max * beta_d_l * f_Abgl '(3.2.8-27)  t_d_l 을 t_h_max으로 사용

                    Q_z_aux_d_l = W_d_hydr_l * e_d_l '(3.2.8-26)
                    'Q_z_aux_d_a = sigma(Q_z_zux_d_l) '(3.2.8-25)

                    Q_c_aux = Q_c_aux + Q_z_aux_d_l * system_count
                End If

                'End If

            Next

        Next    '//for zonerow
    End Sub
    Private Sub Calc_개별기기미적용시(ByRef dr냉방 As DS.tbl_nangbangkikiRow, Mon As String, 비율 As Single, i_count_month As Integer, theta_e As Decimal)

        pLog.Add(String.Format(">>Calc_Calc_개별기기미적용시 냉방기={0},Mon={1},비율={2},월={3},theta_e={4}", dr냉방.code, Mon, 비율, i_count_month, theta_e))

        Dim dr존데이터() As DS.tbl_zoneRow = DSET.tbl_zone.Select("(공조냉방생산기기 = '" & dr냉방.code & "' and 냉난방공조 <> '기능없음' and (외기부하처리여부 = '예' or 냉난방공조 = '냉난방' or 냉난방공조 = '냉방') ) or (열생산냉방생산기기='" & dr냉방.code & "'  and 냉난방방식 <> '난방' and 냉난방방식 <> '기능없음') and code <> '0'", "code")
        If dr존데이터.Length > 0 Then
            Q_c_b = 0
            Q_c_star_b = 0
            t_h_max = 0
            Q_c_f_elektr = 0
            Q_c_outg_therm = 0
            Q_c_g = 0
            Q_c_f_R_elektr = 0
            system_count = 0
            '==================================2014.07.01 수정
            d_op_max_mth = 0
            '==================================2014.07.01 수정

        End If

        For Each Dr존 As DS.tbl_zoneRow In dr존데이터    '//5,1,1
            Dim Drow분석() As DSR.월별에너지분석Row = CType(DSETR.월별에너지분석.Select("월='" & Mon & "' and 존='" & Dr존.code & "'"), DSR.월별에너지분석Row())
            ' 존데이터를가져올떄 해당 냉방기기에서 사용한 존만 가져왔따.
            ' If Dr존.열생산냉방생산기기 <> "" Then ' Worksheets("입력존").Range("입력냉방생산기기1").Offset(0, i_count_zone - 1) <> "" Then
            ' If Dr존.열생산냉방생산기기 = dr냉방.code Then ' Worksheets("입력존").Range("입력냉방생산기기1").Offset(0, i_count_zone - 1) = Worksheets("냉방기기").Range("냉방생산기기1").Offset(0, i_count_chiller - 1) Then

            system_count = 1 ''IIf(dr냉방.개별기기적용 = "0", 1, TOSG(Dr존.입력존의수))   '//20130818

            '=========================================================2014.07.01 수정
            'If dr냉방.헤더적용 Then
            '    Q_c_b_i = A_Q_c_b_i
            '    Q_c_b_i *= 비율 '//130818
            '    Q_c_b = Q_c_b_i '//Q_c_b + Q_c_b_i

            '    Q_c_star_b_i = A_Q_c_star_b_i
            '    Q_c_star_b_i *= 비율 '//130818
            '    Q_c_star_b = Q_c_star_b_i '//Q_c_star_b + Q_c_star_b_i 2014.04.30 수정
            'Else
            If Dr존.열생산냉방생산기기 = dr냉방.code And (Dr존.냉난방방식 = "냉난방" OrElse Dr존.냉난방방식 = "냉방") Then
                Q_c_b_i = Result.E분석(i_count_month).냉방에너지요구량열(Dr존.code) / system_count '2013.08.18 수정 ' CSng(Drow분석(0).냉방요구량열) ' Sheets("" & i_count_month & "").Cells(10, 7 + i_count_zone)
                Q_c_b = Q_c_b + Q_c_b_i
            End If
            If Dr존.공조냉방생산기기 = dr냉방.code And Dr존.냉난방공조 = "냉난방" OrElse Dr존.냉난방공조 = "냉방" OrElse ((Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예") Then
                If (Dr존.냉난방공조 = "환기" OrElse Dr존.냉난방공조 = "난방") And Dr존.외기부하처리여부 = "예" Then '// 2010.11.19 추가
                    Q_c_star_b_i = TOSG(Drow분석(0).냉방요구량공조) / system_count '2013.08.18 수정  '//2010.11.19 추가
                Else
                    Q_c_star_b_i = Result.E분석(i_count_month).공조에너지요구량냉방(Dr존.code) / system_count '2013.08.18 수정 ' CSng(Drow분석(0).공조요구량냉방) ' Sheets("" & i_count_month & "").Cells(21, 7 + i_count_zone)
                End If
                Q_c_star_b = Q_c_star_b + Q_c_star_b_i
            End If
            'End If

            '===================================================================================2010.2.21 수정
            ' Dim Drow최대() As DSR.최대냉난방부하Row = CType(DSETR.최대냉난방부하.Select("zone='" & Dr존.code & "'"), DSR.최대냉난방부하Row())

            '=========================================================2014.07.01 수정
            'If dr냉방.헤더적용 Then
            '    '//헤더로 묶인 냉방기기의 존들에서 
            '    d_op_max_mth = a_d_op_max_mth
            '    t_h_max = a_t_h_max
            'Else
            Dim Dr프로필 As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & Dr존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)
            If i_count_month = 0 Then
                d_op_mth = 0
            Else
                d_op_mth = CInt(Dr프로필("day" & Format(i_count_month, "00")))
            End If
            If d_op_max_mth < d_op_mth Then d_op_max_mth = d_op_mth
            If t_h_max < TOSG(Dr프로필.일일운전시간) * d_op_mth Then t_h_max = CInt(TOSG(Dr프로필.일일운전시간) * d_op_mth)
            'End If

            '===================================================================================2010.2.21 수정
            ' End If
            ' End If
        Next
        '=========================================================2014.07.01 수정
        If dr냉방.헤더적용 Then
            Q_c_b = A_Q_c_b_i * 비율
            Q_c_star_b = A_Q_c_star_b_i * 비율
        End If

        'Q_vh_b = Sheets("" & i_count_month & "").Cells(19, 7 + i_count_zone)
        'Q_vc_b = Sheets("" & i_count_month & "").Cells(21, 7 + i_count_zone)
        'Q_vm_b = Sheets("" & i_count_month & "").Cells(23, 7 + i_count_zone)


        '==========================================================================================================================================
        ' 가열유닛에 대한 사용에너지(3차 에너지)
        ' 외부 공조덕트가 없어서 Q_vh_d 는 0으로 적용

        'Q_dot_V_H_max = V_dot_star_rho_L(c_p_L * (theta_ZUL_wi - theta_AUL_wi) - Delta_h_WRG) '(3.2.5-58)
        'Q_dot_V_H_max = V_dot_star * rho_L(h_ZUL_wi - h_AUL_wi - Delta_h_WRG) '(3.2.5-57)
        'b_VH_a = sigma1_12(b_VH_month) '(3.2.8-7)
        'b_VH_mth = Q_vh_b / Q_dot_V_H_max '(3.2.8-6)
        't_H_r = t_H_r_14_12h + (t_H_r_22_12h - t_H_r_14_12h) * (theta_V_mech - 14) / 8 '(3-B.1) theta_V_mech은 (3-C.1)
        't_H_star_op_mth = t_H_r * b_VH_mth / b_VH_a '(3.2.8-5)
        'Q_vh_d = f_vh_d * A_K_A * t_H_star_opo_mth '(3.2.8-10) f_vh_d=16W/m

        'Q_vh_ce = (1 - eta_vh_ce) * Q_vh_b '(3.2.8-9) eta_vh_ce 는 1로 Q_vh_ce 는 0이 됨
        'Q_h_star_b = Q_vh_b 'Q_h_star_b = Q_vh_b + Q_vh_ce + Q_vh_d '(3.2.8-2)
        '==========================================================================================================================================



        '==========================================================================================================================================
        ' 냉각 유닛에 대한 사용 에너지(3차 에너지)
        ' 외부 공조덕트가 없어서 Q_vc_d 는 0으로 적용

        'Q_dot_V_C_max = V_dot_star * rho_L(h_AUL_so - h_ZUL_so - Delta_h_WRG) '(3.2.5-62)
        'b_VC_a = sigma1_12(b_VC_month) '(3.2.8-13)
        'b_VC_mth = Q_vc_b / Q_dot_V_C_max '(3.2.8-12)
        't_C_r = (t_C_r_14_12h + (t_C_r_22_12h - t_C_r_14_12h) * (theta_V_mech - 14) / 8) * f_h_C '(3-B.2) theta_V_mech은 (3-C.1)
        't_C_star_op_mth = t_C_r * b_VC_mth / b_VC_a '(3.2.8-11)
        'Q_vc_d = f_vc_d * A_K_A * t_C_star_opo_mth '(3.2.8-10) f_vh_d=9W/m
        'Q_vc_ce = (1 - eta_vc_ce) * Q_vc_b '(3.2.8-9) eta_vc_ce 는 1로 Q_vc_ce 는 0이 됨

        'Q_c_star_b = Q_vc_b 'Q_c_star_b = Q_vc_b + Q_vc_ce + Q_vc_d '(3.2.8-8)

        '==========================================================================================================================================


        '가습
        'Q_m_star_b = Q_vm_b '(3.2.8-14)


        ' 실-냉방 냉열 공급

        'Q_c_b = Sheets("" & i_count_month & "").Cells(7, 7 + i_count_zone)

        Q_c_d = (1 - eta_c_d) * Q_c_b '(3.2.8-21) eta_c_d는 (Tab.7-8)
        Q_c_ce = ((1 - eta_c_ce) + (1 - eta_c_ce_sens)) * Q_c_b '(3.2.5-20) eta_c_ce는(Tab.7-8), eta_c_ce_sens는 (Tab.7-7)

        Q_c_outg = Q_c_b + Q_c_ce + Q_c_d + Q_c_s '(3.2.8-19)



        '==========================================================================================================================================
        ' 실-냉방 2차 공기 송풍기의 전기에너지 요구량
        ' 추후 세부 변수 검토

        'beta_c_i = beat_c_we = Q_c_b_we / (Q_c_max_res * t_c_op_we) '(2-D.7)
        'beta_c_i = beta_c_nutz = Q_c_b_nutz / (Q_c_max_res * t_c_op_nutz)
        't_c_i = t_mth_nutz = d_nutz * t_c_op_nutz '(2-D.8) t_c_i=t_mth_we=d_we*t_c_op_we
        't_c_i = t_mth_i * beta_c_i / beta_c_grenz '(2-D.6)
        't_c_op = t_c_NR + t_c_we '(2-D.5)
        'Q_c_outg = Q_c_b + Q_c_ce + Q_c_d + Q_c_s '(3.2.8-19)
        'Q_c_ce_aux = f_c_ce_aux * Q_c_outg * t_c_op / 1000 '(3.2.8-23) f_c_ce_aux 는 (Tab.3.93)
        Q_c_ce_aux = f_c_ce_aux * Q_c_outg * t_h_max / 1000


        '==========================================================================================================================================




        '공조-냉방 냉열 공급

        Q_c_star_d = (1 - eta_c_star_d) * Q_c_star_b '(3.2.8-18) eta_c_star_d는 (Tab.3.91)
        Q_c_star_ce = ((1 - eta_c_star_ce) + (1 - eta_c_star_ce_sens)) * Q_c_star_b '(3.2.8-16) eta_c_star_ce는 (Tab.3.91), eta_c_star_ce_sens는 (Tab.3.91)

        Q_c_star_outg = Q_c_star_b + Q_c_star_ce + Q_c_star_d + Q_c_star_s '(3.2.8-15)
        Q_z_star_outg_l = Q_c_star_outg


        ' 공조기기 가습에 필요한 생산기의 이용열 교부


        'Q_m_star_d = 0
        'Q_m_star_ce = 0
        'Q_m_star_b = Q_vm_b '(3.2.8-14)
        'Q_m_star_outg = Q_m_star_b 'Q_m_star_outg = Q_m_star_b + Q_m_star_ce + Q_m_star_d '(3.2.8-24)


        Q_c_outg_total = Q_c_outg + Q_c_star_outg

        Q_z_outg_l = Q_c_outg_total



        '==================================================================================================================================
        '==================================================================================================================================
        '지열시스템

        Dim CRenew As New CRenewable(DSET, Result)
        If dr냉방.신재생연결여부 = "시스템연결" AndAlso dr냉방.연결된시스템 <> "0" Then ' 시스템연결" Then
            Dim Dr신재생 As DS.tbl_newRow = CType(DSET.tbl_new.Select("code='" & dr냉방.연결된시스템 & "' and code <> '0'")(0), DS.tbl_newRow)
            '//연결되었을시에는 
            Select Case Dr신재생.기기종류.Trim
                Case "태양열" '//태양열
                Case "태양광" '//태양광
                Case "지열" '//지열
                    Select Case Dr신재생.가동연료.Trim
                        Case "전기" '전기"
                            CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                            Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                            Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                            use_Elec = use_Elec + Q_c_f_hp + Q_c_g_hp_aux
                        Case "천연가스" '천연가스"
                            CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                            Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                            Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                            use_LNG = use_LNG + Q_c_f_hp
                            use_Elec = use_Elec + Q_c_g_hp_aux
                        Case "액화가스" '액화가스"
                            CRenew.Calc_HeatpumpSystem(system_type, i_HeatCool, Dr신재생, Q_c_outg_total, i_count_month, d_op_max_mth, t_h_max, theta_VA, theta_i, Q_hp_outg, Q_c_f_hp, Q_c_g_hp_aux)
                            Q_c_outg_total = Q_c_outg_total - Q_hp_outg
                            Q_c_f = Q_c_f + Q_c_f_hp + Q_c_g_hp_aux
                            use_LPG = use_LPG + Q_c_f_hp
                            use_Elec = use_Elec + Q_c_g_hp_aux
                    End Select
                Case "열병합" '//열병합
            End Select
        End If

        '==================================================================================================================================
        '==================================================================================================================================

        EER = TOSG(dr냉방.열성능비) * age ' Dr냉방.열성능비
        Q_dot_c_outg = TOSG(dr냉방.냉동기용량) ' dr냉방.냉동기용량

        If Q_dot_c_outg = 0 Or t_h_max = 0 Then '==================================================================================2014.03.07 추가
            k_n = 0
        Else
            k_n = Q_c_outg_total / (Q_dot_c_outg * t_h_max)
        End If                                  '==================================================================================2014.03.07 추가


        If k_n > 1 Then k_n = 1

        k_n_index = 100 ' 조건에 없는 압축방식에서 에러 발생 유도함

        Select Case dr냉방.냉동기방식.Trim 'Dr냉방.냉동기방식
            Case "압축식", "압축식(LNG)" '압축식"
                T_W_1_i = TOSG(dr냉방.냉각탑입구온도) ' Dr냉방.냉각탑입구온도
                Select Case dr냉방.냉동기종류.Trim ' Dr냉방.냉동기종류
                    Case "수냉식" '수냉식"
                        Select Case dr냉방.냉동기압축방식.Trim ' Dr냉방.냉동기압축방식
                            Case "왕복동/스크롤 압축기" '왕복동/스크롤압축기"
                                Select Case dr냉방.압축기제어방식.Trim 'Dr냉방.압축기제어방식
                                    Case "on/off제어"
                                        k_n_index = 7
                                        f_2_av = 1
                                    Case "다단제어" '다단제어"
                                        k_n_index = 8
                                        Select Case dr냉방.증발식건식냉각기.Trim ' Dr냉방.증발식건식냉각기
                                            Case "증발식" '증발식"
                                                f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                            Case "건식" '건식"
                                                f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                            Case Else
                                                MsgBox("22")
                                        End Select
                                    Case "실린더off"
                                        k_n_index = 9
                                        Select Case dr냉방.증발식건식냉각기.Trim
                                            Case "증발식" '증발식"
                                                f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                            Case "건식" '건식"
                                                f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                            Case Else
                                                MsgBox("21")
                                        End Select
                                    Case "바이패스제어" '바이패스제어"
                                        k_n_index = 10
                                        f_2_av = 1
                                    Case Else
                                        MsgBox("19")
                                End Select
                            Case "스크류압축기" '스크류압축기"
                                k_n_index = 11
                                Select Case dr냉방.증발식건식냉각기.Trim
                                    Case "증발식" '증발식"
                                        f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                    Case "건식" '건식"
                                        f_2_av = TOSG(3.1851 - 0.0486 * T_W_1_i)
                                    Case Else
                                        MsgBox("18")
                                End Select
                            Case "터보압축기" '터보압축기"
                                k_n_index = 12
                                Select Case dr냉방.증발식건식냉각기.Trim
                                    Case "증발식" '증발식"
                                        f_2_av = TOSG(2.0614 - 0.0307 * T_W_1_i)
                                    Case "건식" '건식"
                                        f_2_av = TOSG(2.1181 - 0.0249 * T_W_1_i)
                                    Case Else
                                        MsgBox("16")
                                End Select
                            Case Else
                                MsgBox("17")
                        End Select

                    Case "공냉식" '공냉식"
                        Select Case dr냉방.냉동기압축방식.Trim
                            Case "왕복동/스크롤 압축기" '왕복동/스크롤압축기"
                                Select Case dr냉방.압축기제어방식.Trim
                                    Case "on/off제어"
                                        k_n_index = 0
                                        f_2_av = 1
                                    Case "다단제어" '다단제어"
                                        k_n_index = 1
                                        f_2_av = 1
                                    Case Else
                                        MsgBox("15")
                                End Select
                            Case "스크류압축기" '스크류압축기"
                                k_n_index = 2
                                f_2_av = 1
                            Case Else
                                MsgBox("14")
                        End Select

                    Case "실내공조시스템" '실내공조시스템"
                        Select Case dr냉방.냉동기설비시스템.Trim ' Dr냉방.냉동기설비시스템
                            Case "콤팩트형시스템" '콤팩트형시스템"
                                k_n_index = 3
                                f_2_av = 1
                            Case "실내외분리시스템" '실내외분리시스템"
                                Select Case dr냉방.제어방식.Trim.ToLower '냉동기설비시스템의제어방식 Dr냉방.제어방식
                                    Case "on/off제어"
                                        k_n_index = 3
                                        f_2_av = 1
                                    Case "회전수제어" '회전수제어"
                                        k_n_index = 5
                                        f_2_av = 1
                                    Case Else
                                        MsgBox(dr냉방.제어방식.Trim)
                                End Select
                            Case "멀티분리시스템" '멀티분리시스템"
                                Select Case dr냉방.제어방식.Trim
                                    Case "on/off제어"
                                        k_n_index = 4
                                        f_2_av = 1
                                    Case "회전수제어" '회전수제어"
                                        k_n_index = 6
                                        f_2_av = 1
                                    Case Else
                                        MsgBox("11")
                                End Select
                            Case Else
                                MsgBox("13")
                        End Select
                    Case Else
                        MsgBox("30")
                End Select
                '//이부분정확히 살펴보아야할듯 
                If k_n = 0 Then k_n = 0.001 ' 부분부하율이 0일 경우 부분부하를 0에서 0.1구간으로 설정
                'Dim Drow부분부하() As DS.tbl_buhaRow = DSET.tbl_buha.Rows(k_n_index) '.Select("code='" & Format(9 - Int((1 - k_n) * 10), "00") & "'")

                If k_n_index >= 100 Then
                    LogSB.AppendLine("냉방기기(" & dr냉방.설명 & ")의 냉동기방식(" & dr냉방.냉동기방식.Trim & ")에따른 종류(" & dr냉방.냉동기종류.Trim & ")를 확인할 수 없습니다")
                    Return
                Else
                    f_1_av_up = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 2)))
                    If k_n < 0.1 Then
                        f_1_av_dn = f_1_av_up
                    Else
                        f_1_av_dn = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 1)))
                    End If
                    f_1_av = f_1_av_up - (f_1_av_up - f_1_av_dn) * (1 - (k_n * 10 - Int(k_n * 10)))

                    'f_1_av = TOSG(DSET.tbl_buha.Rows(k_n_index)(CInt(9 - Int((1 - k_n) * 10) + 2))) ' Worksheets("부분부하율").Range("냉동기부분부하율1").Offset(k_n_index, 9 - Int((1 - k_n) * 10))
                End If

                PLV_av = f_1_av * f_2_av

                ' If i_count_month = 8 Then
                ' Dim data As String = vbCrLf + "미적용시 " + i_count_month.ToString() + "월  ply_av=" + PLV_av.ToString()
                ' My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\kn.txt", data, True, System.Text.Encoding.Default)
                ' End If

                If PLV_av = 0 Then '===========================================================================2014.03.07 추가
                    Q_c_f_elektr = 0
                    Q_c_outg_therm = 0
                Else
                    If dr냉방.냉동기방식 = "압축식" Then
                        Q_c_f_elektr = Q_c_outg_total / (EER * PLV_av)
                        '======================================================================= 2010.10.5 추가
                    ElseIf dr냉방.냉동기방식 = "압축식(LNG)" Then
                        Q_c_outg_therm = Q_c_outg_total / (EER * PLV_av)
                        use_LNG = use_LNG + Q_c_outg_therm
                        '======================================================================= 2010.10.5 추가
                    End If
                End If '===========================================================================2014.03.07 추가


                
                If (dr냉방.냉동기방식 = "압축식" Or dr냉방.냉동기방식 = "압축식(LNG)") And dr냉방.냉동기종류 = "수냉식" Then 'If Dr냉방.냉동기방식 = "압축식" And Dr냉방.냉동기종류 = "수냉식" Then
                    Q_dot_R_outg = Q_dot_c_outg * (1 + 1 / EER)
                    Select Case dr냉방.증발식건식냉각기.Trim
                        Case "증발식" '증발식"
                            l_min_i = TOSG(1.2103 - 0.0162 * theta_e) '원래는 습구온도로 입력요망 우선 외기건구온도로 입력 추후 수정
                            'f_R_av = (Log(1 - 0.5 / 0.8) * l_min_i / (Log(1 - 0.5 / 0.8) * 0.87)) ^ 2 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정

                            If Q_dot_c_outg = 0 Or t_h_max = 0 Then '====================================================================2014.03.07 추가
                                f_R_av = 0
                            Else
                                f_R_av = Q_c_outg_total * 4 / (Q_dot_c_outg * t_h_max) ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                            End If           '====================================================================2014.03.07 추가




                            If f_R_av > 1 Then f_R_av = 1 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산하고 최대가동시간 이하로 계산 추후 수정
                            Select Case dr냉방.증발식냉각기.Trim 'Dr냉방.증발식냉각기
                                Case "폐쇄형" '폐쇄형"
                                    Select Case dr냉방.보조방음기유무.Trim 'Dr냉방.보조방음기유무
                                        Case "아니오" '아니오"
                                            q_R_elektr = 0.033
                                        Case "예" '예"
                                            q_R_elektr = 0.04
                                    End Select
                                Case "개방형" '개방형"
                                    Select Case dr냉방.보조방음기유무.Trim
                                        Case "아니오" '아니오"
                                            q_R_elektr = 0.018
                                        Case "예" '예"
                                            q_R_elektr = 0.021
                                    End Select
                            End Select
                        Case "건식" '건식"
                            f_R_av = 1 '우선 1로 적용 추후 검토
                            q_R_elektr = 0.045
                    End Select
                    Q_c_f_R_elektr = Q_dot_R_outg * q_R_elektr * f_R_av * t_h_max
                Else
                    Q_c_f_R_elektr = 0
                End If


            Case "흡수식" '흡수식"
                Q_dot_R_outg = Q_dot_c_outg * (1 + 1 / EER)
                T_W_1_i = TOSG(dr냉방.냉각탑입구온도)
                Select Case dr냉방.증발식건식냉각기.Trim
                    Case "증발식" '증발식"
                        l_min_i = TOSG(1.2103 - 0.0162 * theta_e) '원래는 습구온도로 입력요망 우선 외기건구온도로 입력 추후 수정
                        'f_R_av = (Log(1 - 0.5 / 0.8) * l_min_i / (Log(1 - 0.5 / 0.8) * 0.87)) ^ 2 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                        If Q_dot_c_outg = 0 Or t_h_max = 0 Then '====================================================================2014.03.07 추가
                            f_R_av = 0
                        Else
                            f_R_av = Q_c_outg_total * 4 / (Q_dot_c_outg * t_h_max) ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산 추후 수정
                        End If           '====================================================================2014.03.07 추가
                        If f_R_av > 1 Then f_R_av = 1 ' 냉각탑 가동시간을 부분부하 25%이상이면 가동하는 것으로 계산하고 최대가동시간 이하로 계산 추후 수정
                        Select Case dr냉방.증발식냉각기.Trim
                            Case "폐쇄형"
                                Select Case dr냉방.보조방음기유무.Trim
                                    Case "아니오"
                                        q_R_elektr = 0.033
                                    Case "예"
                                        q_R_elektr = 0.04
                                End Select
                            Case "개방형"
                                Select Case dr냉방.보조방음기유무.Trim
                                    Case "아니오"
                                        q_R_elektr = 0.018
                                    Case "예"
                                        q_R_elektr = 0.021
                                End Select
                        End Select
                    Case "건식" '건식"
                        f_R_av = 1 '우선 1로 적용 추후 검토
                        q_R_elektr = 0.045
                End Select
                Q_c_f_R_elektr = Q_dot_R_outg * q_R_elektr * f_R_av * t_h_max

                Select Case dr냉방.증발식건식냉각기.Trim
                    Case "증발식"
                        f_2_av = TOSG(1.7174 - 0.0217 * T_W_1_i)
                    Case "건식"
                        f_2_av = TOSG(2.3235 - 0.0294 * T_W_1_i)
                    Case Else
                        'MsgBox("증발식건식냉각기를 확인할 수 없습니다" & vbCrLf & "Calc_CoolingSystem 429번줄 Case else 를 입력하세요", MsgBoxStyle.Critical, dr냉방.증발식건식냉각기)

                End Select

                '//13번째줄
                If k_n = 0 Then k_n = 0.01 ' 부분부하율이 0일 경우 부분부하를 0에서 0.1구간으로 설정
                f_1_av_up = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 2)))
                If k_n < 0.1 Then
                    f_1_av_dn = f_1_av_up
                Else
                    f_1_av_dn = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 1)))
                End If
                f_1_av = f_1_av_up - (f_1_av_up - f_1_av_dn) * (1 - (k_n * 10 - Int(k_n * 10)))
                'f_1_av = TOSG(DSET.tbl_buha.Rows(13)(CInt(9 - Int((1 - k_n) * 10) + 2))) 'Worksheets("부분부하율").Range("냉동기부분부하율1").Offset(13, 9 - Int((1 - k_n) * 10))
                PLV_av = f_1_av * f_2_av

                If PLV_av = 0 Then '==============================================2014.03.07 추가
                    Q_c_outg_therm = 0
                Else
                    Q_c_outg_therm = Q_c_outg_total / (EER * PLV_av)
                End If '==============================================2014.03.07 추가



                ': 흡수식 냉동기에서 사용되는 보일러의 생산손실에너지 계산
                If dr냉방.열생산연결방식.ToString = "외부연결" Then '==============================2010.04.02 if문 추가


                    '//냉방의 온수열생산기기로 지정된 난방기기만을 취한다 10.02.23 최적화중변경
                    For Each Dr난방 As DS.tbl_nanbangkikiRow In DSET.tbl_nanbangkiki.Select("code = '" & dr냉방.온수열생산기기 & "' and code <> '0'", "code")
                        'If Dr난방.code = dr냉방.온수열생산기기 Then ' Dr냉방.온수열생산기기 Then

                        theta_VA = TOSG(Dr난방.급수온도) ' Worksheets("난방기기").Range("난방기기급수온도1").Offset(0, i_count_c_d - 1)
                        theta_RA = TOSG(Dr난방.환수온도) ' Worksheets("난방기기").Range("난방기기환수온도1").Offset(0, i_count_c_d - 1)

                        theta_HK_m_beta_h_d = TOSG(0.5 * (theta_VA + theta_RA))

                        '----------------------------------------------------------------------------------------------------------------------------------
                        '----------------------------------------------------------------------------------------------------------------------------------

                        '신재생 및 열병합 시스템
                        Dim CNew As New CRenewable(DSET, Result)
                        If Dr난방.신재생연결여부 = "시스템연결" AndAlso Dr난방.연결된시스템 <> "0" Then ' Worksheets("난방기기").Range("신재생난방연결1").Offset(0, i_count_c_d - 1) = "시스템연결" Then
                            Dim Dr신재생 As DS.tbl_newRow = CType(DSET.tbl_new.Select("code='" & Dr난방.연결된시스템 & "' and code <> '0'")(0), DS.tbl_newRow)
                            Select Case Dr신재생.기기종류.Trim
                                Case "태양열" '//태양열
                                    '========================================================================================2010.04.02 추가
                                    If Q_c_outg_therm > 0 Then
                                        Calc.Renewable.Calc_ThermalSolarSystem_EN(system_type, Dr신재생.code, i_count_month, d_op_max_mth, Q_h_outg_i, Q_c_outg_therm, Q_W_sol_out_m, Q_H_sol_out_m, W_sol_aux_m)
                                        Q_c_outg_therm = Q_c_outg_therm - Q_W_sol_out_m
                                        Q_c_aux = Q_c_aux + W_sol_aux_m
                                    End If
                                    '========================================================================================2010.04.02 추가
                                Case "태양광" '//태양광
                                Case "지열" '//지열                                           
                                Case "열병합" '//열병합
                                    If Q_c_outg_therm > 0 Then '===========================2010.04.02  And Q_c_outg_therm > 0 추가
                                        Select Case Dr신재생.가동연료.Trim
                                            Case "난방유" '난방유"
                                                CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                use_Oil = use_Oil + Q_c_f_chp

                                            Case "천연가스" '천연가스"
                                                CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                use_LNG = use_LNG + Q_c_f_chp

                                            Case "액화가스" '액화가스"
                                                CNew.Calc_CogenerationSystemEN(Dr신재생, 2, i_count_month, Q_c_outg_therm, t_h_max, Q_chp_outg, Q_c_f_chp)
                                                Q_c_outg_therm = Q_c_outg_therm - Q_chp_outg
                                                use_LPG = use_LPG + Q_c_f_chp

                                        End Select
                                    End If

                            End Select
                        End If


                        '----------------------------------------------------------------------------------------------------------------------------------
                        '----------------------------------------------------------------------------------------------------------------------------------


                        If Dr난방.열생산기기방식 = "보일러" Then ' Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1) = "보일러" Then

                            Q_dot_N = TOSG(Dr난방.정격보일러효율) * age_heating ' Worksheets("난방기기").Range("난방기기정격출력1").Offset(0, i_count_c_d - 1)

                            If t_h_max = 0 Then '===========================================================2014.03.07 추가
                                beta_h = 0
                            Else
                                Q_dot_d_in = Q_c_outg_therm / t_h_max

                                Select Case Dr난방.운전방식.Trim ' Worksheets("난방기기").Range("난방기기운전방식1").Offset(0, i_count_c_d - 1)
                                    Case "단독가동" '단독가동"
                                        beta_h = Q_dot_d_in / Q_dot_N '(3.2.7-64) : 단일보일러 시설
                                    Case "동시가동" ' 동시가동"
                                        beta_h = Q_dot_d_in / (Q_dot_N * TOSG(Dr난방.보일러대수)) ' Worksheets("난방기기").Range("난방기기운전방식1").Offset(1, i_count_c_d - 1)) '(3.2.7-64) : 다수보일러 동시가동
                                    Case "순차가동" '순차가동"
                                        For i_count_beta = 1 To CInt(TOSG(Dr난방.보일러대수))
                                            If Q_dot_d_in <= (Q_dot_N * i_count_beta) Then
                                                beta_h = (Q_dot_d_in - Q_dot_N * (i_count_beta - 1)) / Q_dot_N * i_count_beta '다수보일러 대수제어
                                                n_beta = i_count_beta - 1
                                                Exit For
                                            End If
                                        Next
                                End Select
                            End If  '===========================================================2014.03.07 추가

                            


                            eta_k_100 = TOSG(Dr난방.정격보일러효율) * age_heating / 100 'Worksheets("난방기기").Range("난방기기정격효율1").Offset(0, i_count_c_d - 1) / 100
                            eta_k_pl = eta_k_100
                            f = -0.4
                            Select Case Dr난방.보일러방식.Trim 'Worksheets("난방기기").Range("보일러방식1").Offset(0, i_count_c_d - 1)
                                Case "가스보일러" '가스보일러"
                                    e = 8.5
                                    f = -0.4
                                Case "기름보일러" '기름보일러"
                                    e = 8.5
                                    f = -0.4
                                Case "저온가스보일러" '저온가스보일러"
                                    e = 4.5
                                    f = -0.4
                                Case "저온기름보일러" '저온기름보일러"
                                    e = 4.25
                                Case "콘덴싱보일러" '콘덴싱보일러"
                                    e = 4
                            End Select

                            q_B_70 = TOSG((e * (Q_dot_N ^ f)) / 100)
                            q_B_theta = q_B_70 '원래는 =q_B_70 * (theta_HK_m_beta_h_g - theta_i) / (70 - 20) 이지만 q_B_theta 와 q_B_70 이 같은 것으로 적용 추후검토

                            'Select Case Worksheets("난방기기").Range("난방기기사용연료1").Offset(0, i_count_c_d - 1)
                            'Case "난방유"
                            'f_Hs_Hi = 1.06
                            'Case "천연가스"
                            'f_Hs_Hi = 1.11
                            'Case "액화가스"
                            'f_Hs_Hi = 1.09
                            'Case "석탄"
                            'f_Hs_Hi = 1.04
                            'Case "갈탄"
                            'f_Hs_Hi = 1.07
                            'Case "나무"
                            'f_Hs_Hi = 1.08
                            'End Select

                            f_Hs_Hi = 1 ' 국내는 총발열량을 기준으로 입력함으로 우선 1로 설정, 추후 검토

                            Q_dot_B_h = q_B_theta * (Q_dot_N / eta_k_100) * f_Hs_Hi '(3.2.7-71)

                            Q_V_g_100 = (f_Hs_Hi - eta_k_100) / eta_k_100 * Q_dot_N
                            Q_V_g_pl = (f_Hs_Hi - eta_k_pl) / eta_k_pl * beta_k_pl * Q_dot_N

                            '------------------------------------------------------------------------------------------------------

                            If beta_h > beta_k_pl Then
                                Q_c_g_v_i = ((beta_h - beta_k_pl) / (1 - beta_k_pl) * (Q_V_g_100 - Q_V_g_pl) + Q_V_g_pl)
                                Q_c_g_v_i = Q_c_g_v_i + ((Q_V_g_100 - Q_V_g_pl) + Q_V_g_pl) * n_beta
                            Else
                                Q_c_g_v_i = ((beta_h / beta_k_pl) * (Q_V_g_pl - Q_dot_B_h) + Q_dot_B_h)
                            End If


                            Q_c_g = Q_c_g_v_i * t_h_max '  추후 검토

                        Else

                            ':지역난방의 경우 적용 추후 검토
                            Q_c_g = 0

                        End If

                        If Dr난방.열생산기기방식 = "보일러" Then 'Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1) = "보일러" Then
                            Select Case Dr난방.사용연료.Trim ' Worksheets("난방기기").Range("난방기기사용연료1").Offset(0, i_count_c_d - 1)
                                Case "난방유" '난방유"
                                    use_Oil = use_Oil + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                                Case "천연가스" '천연가스"
                                    use_LNG = use_LNG + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                                Case "액화가스" '액화가스"
                                    use_LPG = use_LPG + (Q_c_g + Q_c_outg_therm) * system_count '========2013.0818 수정

                            End Select
                        Else
                            Select Case Dr난방.열생산기기방식.Trim 'Worksheets("난방기기").Range("열생산기기방식1").Offset(0, i_count_c_d - 1)
                                Case "지역난방" '지역난방"
                                    use_DH = use_DH + Q_c_outg_therm * system_count '========2013.0818 수정

                                Case "전기보일러" '전기보일러"
                                    use_Elec = use_Elec + Q_c_outg_therm * system_count '========2013.0818 수정

                            End Select

                        End If


                        ' End If


                    Next
                    '=================================================================================================2010.04.02 if문 추가
                ElseIf dr냉방.열생산연결방식 = "직화식" Then
                    Select Case dr냉방.사용연료.ToString
                        Case "난방유"
                            use_Oil = use_Oil + Q_c_outg_therm * system_count '========2013.0818 수정
                        Case "천연가스"
                            use_LNG = use_LNG + Q_c_outg_therm * system_count '========2013.0818 수정
                        Case "액화가스"
                            use_LPG = use_LPG + Q_c_outg_therm * system_count '========2013.0818 수정
                        Case Else
                            MsgBox("냉동기기(" & dr냉방.설명 & ")가 직화식이나 사용연료가 없습니다.확인바랍니다.", vbOKOnly, "건물 에너지 평가 프로그램(ECO2)")
                    End Select
                Else
                    MsgBox("냉동기기(" & dr냉방.설명 & ")의 열생산연결방식을 확인바랍니다.", vbOKOnly, "건물 에너지 평가 프로그램(ECO2)")
                End If

                '=================================================================================================2010.04.02 if문 추가
            Case "지역냉방" '지역냉방"
                '--------------------------------------------------------------------------------------------------2010.02.22 수정
                use_DC = use_DC + Q_c_outg_total * system_count
                '--------------------------------------------------------------------------------------------------2010.02.22 수정
                Q_c_outg_therm = Q_c_outg_total

        End Select

        Q_c_f = Q_c_f + (Q_c_f_elektr + Q_c_f_R_elektr + Q_c_outg_therm + Q_c_g) * system_count
        use_Elec = use_Elec + (Q_c_f_elektr + Q_c_f_R_elektr) * system_count


        'If i_count_month = 6 Then
        '    i_count_month = 6
        'End If
        ' 분배에 대한 전기 에너지 소비
        For Each Dr분배 As DS.tbl_bunbaeRow In DSET.tbl_bunbae.Select("냉동기='" & dr냉방.code & "' and code <> '0'", "code")
            'If Dr분배.냉동기 = dr냉방.code Then ' Worksheets("냉방분배시스템").Range("냉동기분배1").Offset(0, i_count_c_d - 1) = Worksheets("냉방기기").Range("냉방생산기기1").Offset(0, i_count_chiller - 1) Then

            Q_dot_z = Q_dot_c_outg * (1 + 1 / EER) '(3.2.8-30)
            Delta_theta_z_cl = TOSG(Dr분배.설정점에서의온도차) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(3, i_count_c_d - 1) 6
            c_cl = TOSG(Dr분배.냉매의비열) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(4, i_count_c_d - 1) 4.18
            rho_cl = TOSG(Dr분배.냉매의밀도) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(5, i_count_c_d - 1)   1000
            V_dot_z = (3600 * Q_dot_z) / (Delta_theta_z_cl * c_cl * rho_cl) '(3.2.8-29)
            L = TOSG(Dr분배.공급범위의길이) ' Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(0, i_count_c_d - 1)
            b = TOSG(Dr분배.공급범위의넓이) 'Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(1, i_count_c_d - 1)
            n_G = TOSG(Dr분배.열층의수) ' Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(2, i_count_c_d - 1)
            h_G = TOSG(Dr분배.층고) 'Worksheets("냉방분배시스템").Range("공급범위길이1").Offset(3, i_count_c_d - 1)
            L_max = 2 * (L + b / 2 + h_G * n_G + 10) '(3.2.8-32)
            R = TOSG(Dr분배.배관의압력손실) ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(7, i_count_c_d - 1)  0.3
            z = TOSG(Dr분배.개별저항비율) '("냉방분배시스템").Range("급수온도1").Offset(8, i_count_c_d - 1) 0.4
            Delta_P_WUE = TOSG(Dr분배.생산기기압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(0, i_count_c_d - 1)
            Delta_P_WUV = TOSG(Dr분배.사용기기압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(1, i_count_c_d - 1)
            Delta_P_RV = TOSG(Dr분배.제어밸브압력손실) ' Worksheets("냉방분배시스템").Range("생산기기압력손실1").Offset(2, i_count_c_d - 1)

            Delta_p_z = R * L_max * (1 + z) + Delta_P_WUE + Delta_P_RV + Delta_P_WUV '(3.2.8-31) R(7-Tab.11), Delta_P_WUE, Delta_P_RV, Delta_P_WUV (7-Tab.12)

            P_d_hydr = 1000 * Delta_p_z * V_dot_z / 3600 '(3.2.8-28)

            'f_e = f_dash_e * (1 + (nu_cl ^ 2 / (16 * P_d_hydr)) ^ 0.4) '기존건물 관련
            'f_e = (1.25 + (200 / P_d_hydr) ^ 0.5) * f_Adap * b '(3.2.8-38) '기존건물 관련
            P_Pump = TOSG(Dr분배.펌프동력) 'Worksheets("냉방분배시스템").Range("급수온도1").Offset(9, i_count_c_d - 1)
            'P_Pump = Worksheets("냉방분배시스템").Range("급수온도1").Offset(9, i_count_c_d - 1) << 이거오류인듯 펌프는 8번인덱스여야한다.9번줄에는 아무것도 없다.

            If P_d_hydr = 0 Then '========================================================2014.03.07 추가
                f_e = 0
            Else
                f_e = P_Pump / P_d_hydr '원래는 P_hydr '(3.2.8-37)
            End If '========================================================2014.03.07 추가



            If Dr분배.펌프운전제어유무 = "제어" Then ' Worksheets("냉방분배시스템").Range("급수온도1").Offset(-1, i_count_c_d - 1) = "제어" Then
                c_p1 = 0.85
                c_p2 = 0.15
            ElseIf Dr분배.펌프운전제어유무 = "대수제어" Then
                c_p1 = 0.75
                c_p2 = 0.25
            Else
                c_p1 = 0.25
                c_p2 = 0.75
            End If

            'beta_d_l = beta_dash_ + (1 - beta_dash_d_l) * V_dot_z_min / V_dot_z '(3.2.8-35)
            If Q_z_outg_l <> 0 Then

                If Q_dot_z = 0 Or t_h_max = 0 Then '======================================================2014.03.07 추가

                Else
                    beta_d_l = Q_z_outg_l / (Q_dot_z * t_h_max) '(3.2.8-34) t_d_l 을 t_h_max으로 사용

                    e_d_l = f_e * (c_p1 + c_p2 / beta_d_l) '(3.2.8-36)

                    W_d_hydr_l = P_d_hydr / 1000 * t_h_max * beta_d_l * f_Abgl '(3.2.8-27)  t_d_l 을 t_h_max으로 사용

                    Q_z_aux_d_l = W_d_hydr_l * e_d_l '(3.2.8-26)
                    'Q_z_aux_d_a = sigma(Q_z_zux_d_l) '(3.2.8-25)

                    Q_c_aux = Q_c_aux + Q_z_aux_d_l * system_count
                End If '======================================================2014.03.07 추가

                
            End If

            'End If

        Next    '//for Dr분배


    End Sub
End Class
