<commit_before>"""
Vapor-compressor chiller
"""
from __future__ import division
import pandas as pd
from math import log
from cea.optimization.constants import VCC_T_COOL_IN



__author__ = "<NAME>"
__copyright__ = "Copyright 2015, Architecture and Building Systems - ETH Zurich"
__credits__ = ["<NAME>", "<NAME>", "<NAME>"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"


# technical model

def calc_VCC(mdot_kgpers, T_sup_K, T_re_K, gV):
    """
    For the operation of a Vapor-compressor chiller between a district cooling network and a condenser with fresh water
    to a cooling tower following [D.J. Swider, 2003]_.

    :type mdot_kgpers : float
    :param mdot_kgpers: plant supply mass flow rate to the district cooling network
    :type T_sup_K : float
    :param T_sup_K: plant supply temperature to DCN
    :type T_re_K : float
    :param T_re_K: plant return temperature from DCN
    :param gV: globalvar.py

    :rtype wdot : float
    :returns wdot: chiller electric power requirement
    :rtype qhotdot : float
    :returns qhotdot: condenser heat rejection

    ..[D.J. Swider, 2003] D.J. Swider (2003). A comparison of empirically based steady-state models for
    vapor-compression liquid chillers. Applied Thermal Engineering.

    """
    qcolddot_W = mdot_kgpers * gV.cp * (T_re_K - T_sup_K)      # required cooling at the chiller evaporator
    tcoolin_K = VCC_T_COOL_IN                     # condenser water inlet temperature in [K]
    
    if qcolddot_W == 0:
        wdot_W = 0
        
    else: 
        #Tim Change:
        #COP = (tret / tcoolin - 0.0201E-3 * qcolddot / tcoolin) \
        #  (0.1980E3 * tret / qcolddot + 168.1846E3 * (tcoolin - tret) / (tcoolin * qcolddot) \
        #  + 0.0201E-3 * qcolddot / tcoolin + 1 - tret / tcoolin)
        
        A = 0.0201E-3 * qcolddot_W / tcoolin_K
        B = T_re_K / tcoolin_K
        C = 0.1980E3 * T_re_K / qcolddot_W + 168.1846E3 * (tcoolin_K - T_re_K) / (tcoolin_K * qcolddot_W)
        
        COP = 1 /( (1+C) / (B-A) -1 )
        
        wdot_W = qcolddot_W / COP
         
    qhotdot_W = wdot_W + qcolddot_W
    
    return wdot_W, qhotdot_W
<commit_msg>minor commit<commit_after>"""
Vapor-compressor chiller
"""
from __future__ import division
import pandas as pd
from math import log
from cea.optimization.constants import VCC_T_COOL_IN
from cea.constants import HEAT_CAPACITY_OF_WATER_JPERKGK



__author__ = "<NAME>"
__copyright__ = "Copyright 2015, Architecture and Building Systems - ETH Zurich"
__credits__ = ["<NAME>", "<NAME>", "<NAME>"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"


# technical model

def calc_VCC(mdot_kgpers, T_sup_K, T_re_K):
    """
    For the operation of a Vapor-compressor chiller between a district cooling network and a condenser with fresh water
    to a cooling tower following [D.<NAME>, 2003]_.

    :type mdot_kgpers : float
    :param mdot_kgpers: plant supply mass flow rate to the district cooling network
    :type T_sup_K : float
    :param T_sup_K: plant supply temperature to DCN
    :type T_re_K : float
    :param T_re_K: plant return temperature from DCN
    :rtype wdot : float
    :returns wdot: chiller electric power requirement
    :rtype qhotdot : float
    :returns qhotdot: condenser heat rejection

    ..[<NAME>, 2003] <NAME> (2003). A comparison of empirically based steady-state models for
    vapor-compression liquid chillers. Applied Thermal Engineering.

    """
    q_cold_dot_W = mdot_kgpers * HEAT_CAPACITY_OF_WATER_JPERKGK * (T_re_K - T_sup_K) # required cooling at the chiller evaporator
    T_cool_in_K = VCC_T_COOL_IN # condenser water inlet temperature in [K]
    
    if q_cold_dot_W == 0:
        w_dot_W = 0
        
    else: 
        #Tim Change:
        #COP = (tret / tcoolin - 0.0201E-3 * qcolddot / tcoolin) \
        #  (0.1980E3 * tret / qcolddot + 168.1846E3 * (tcoolin - tret) / (tcoolin * qcolddot) \
        #  + 0.0201E-3 * qcolddot / tcoolin + 1 - tret / tcoolin)
        
        A = 0.0201E-3 * q_cold_dot_W / T_cool_in_K
        B = T_re_K / T_cool_in_K
        C = 0.1980E3 * T_re_K / q_cold_dot_W + 168.1846E3 * (T_cool_in_K - T_re_K) / (T_cool_in_K * q_cold_dot_W)
        
        COP = 1 /( (1+C) / (B-A) -1 )
        
        w_dot_W = q_cold_dot_W / COP
         
    q_hot_dot_W = w_dot_W + q_cold_dot_W
    
    return w_dot_W, q_hot_dot_W

{'fraction_non_alphanumeric': 0.09397321428571428, 'fraction_numerical': 0.03125, 'mean_word_length': 2.7310574521232307, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6410166', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1629, 'n_words': 456}