def test_adaptive_ashrae():
    data_test_adaptive_ashrae = [  # I have commented the lines of code that don't pass the test
        {'tdb': 19.6, 'tr': 19.6, 't_running_mean': 17, 'v': 0.1, 'return': {'acceptability_80': True}},
        {'tdb': 19.6, 'tr': 19.6, 't_running_mean': 17, 'v': 0.1, 'return': {'acceptability_90': False}},
        {'tdb': 19.6, 'tr': 19.6, 't_running_mean': 25, 'v': 0.1, 'return': {'acceptability_80': False}},
        {'tdb': 19.6, 'tr': 19.6, 't_running_mean': 25, 'v': 0.1, 'return': {'acceptability_80': False}},
        {'tdb': 26, 'tr': 26, 't_running_mean': 16, 'v': 0.1, 'return': {'acceptability_80': True}},
        {'tdb': 26, 'tr': 26, 't_running_mean': 16, 'v': 0.1, 'return': {'acceptability_90': False}},
        {'tdb': 30, 'tr': 26, 't_running_mean': 16, 'v': 0.1, 'return': {'acceptability_80': False}},
        {'tdb': 25, 'tr': 25, 't_running_mean': 23, 'v': 0.1, 'return': {'acceptability_80': True}},
        {'tdb': 25, 'tr': 25, 't_running_mean': 23, 'v': 0.1, 'return': {'acceptability_90': True}},
    ]
    for row in data_test_adaptive_ashrae:
        assert (adaptive_ashrae(row['tdb'], row['tr'], row['t_running_mean'], row['v'])[list(row['return'].keys())[0]]) == row['return'][list(row['return'].keys())[0]]

    assert (adaptive_ashrae(77, 77, 68, 0.3, units='ip')['tmp_cmf']) == 75.2

    with pytest.raises(ValueError):
        adaptive_ashrae(20, 20, 9, 0.1)

    with pytest.raises(ValueError):
        adaptive_ashrae(20, 20, 34, 0.1)
예제 #2
0
from pythermalcomfort.models import adaptive_ashrae
from pythermalcomfort.psychrometrics import running_mean_outdoor_temperature
from pprint import pprint

result = adaptive_ashrae(tdb=25, tr=25, t_running_mean=23, v=0.3)

pprint(result)

print(result['acceptability_80'])

result = adaptive_ashrae(tdb=77, tr=77, t_running_mean=73.5, v=1, units='IP')

pprint(result)

print(result['acceptability_80'])

rmt_value = running_mean_outdoor_temperature([29, 28, 30, 29, 28, 30, 27],
                                             alpha=0.9)

result = adaptive_ashrae(tdb=25, tr=25, t_running_mean=rmt_value, v=0.3)
pprint(result)
예제 #3
0
def test_adaptive_ashrae():
    data_test_adaptive_ashrae = (
        [  # I have commented the lines of code that don't pass the test
            {
                "tdb": 19.6,
                "tr": 19.6,
                "t_running_mean": 17,
                "v": 0.1,
                "return": {
                    "acceptability_80": True
                },
            },
            {
                "tdb": 19.6,
                "tr": 19.6,
                "t_running_mean": 17,
                "v": 0.1,
                "return": {
                    "acceptability_90": False
                },
            },
            {
                "tdb": 19.6,
                "tr": 19.6,
                "t_running_mean": 25,
                "v": 0.1,
                "return": {
                    "acceptability_80": False
                },
            },
            {
                "tdb": 19.6,
                "tr": 19.6,
                "t_running_mean": 25,
                "v": 0.1,
                "return": {
                    "acceptability_80": False
                },
            },
            {
                "tdb": 26,
                "tr": 26,
                "t_running_mean": 16,
                "v": 0.1,
                "return": {
                    "acceptability_80": True
                },
            },
            {
                "tdb": 26,
                "tr": 26,
                "t_running_mean": 16,
                "v": 0.1,
                "return": {
                    "acceptability_90": False
                },
            },
            {
                "tdb": 30,
                "tr": 26,
                "t_running_mean": 16,
                "v": 0.1,
                "return": {
                    "acceptability_80": False
                },
            },
            {
                "tdb": 25,
                "tr": 25,
                "t_running_mean": 23,
                "v": 0.1,
                "return": {
                    "acceptability_80": True
                },
            },
            {
                "tdb": 25,
                "tr": 25,
                "t_running_mean": 23,
                "v": 0.1,
                "return": {
                    "acceptability_90": True
                },
            },
        ])
    for row in data_test_adaptive_ashrae:
        assert (adaptive_ashrae(
            row["tdb"], row["tr"], row["t_running_mean"],
            row["v"])[list(row["return"].keys())[0]]) == row["return"][list(
                row["return"].keys())[0]]

    assert (adaptive_ashrae(77, 77, 68, 0.3, units="ip")["tmp_cmf"]) == 75.2

    with pytest.raises(ValueError):
        adaptive_ashrae(20, 20, 9, 0.1)

    with pytest.raises(ValueError):
        adaptive_ashrae(20, 20, 34, 0.1)
예제 #4
0
if pmv <= float(0.5) and pmv >= float(-0.5):
    print('Acceptable!')

if pmv >= 0.5:
    print('Too warm!Turn on fan')

if pmv <= -0.5:
    print('Too cold! Turn on heater! or Grab Blanket')

##################################################################
#finding the setpoints

t_running_mean = 68  ### this will need to be calculated based on the past couple of hours

setpoints = adaptive_ashrae(tdb, tr, t_running_mean, v, units="IP")
#print(setpoints)

print(f"low={setpoints['tmp_cmf_90_low']}, high={setpoints['tmp_cmf_90_up']}%")

if pmv < -0.5 & pmv > 0.5:
    if occupancy == 1:
        #checking if the change fixed it summer
        setpoint_low = setpoints['tmp_cmf_90_low']
        tg = tdb + 2  #can adjust this guess based on how the gt in the fridge changes with the heating or cooling
        tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

        results_low = pmv_ppd(tdb=tdb,
                              tr=tr,
                              vr=vr,
                              rh=rh,
예제 #5
0
def comfortAnalysis(count, tdb, tg, rh, tout, occupancy):
    #START###########################################
    #TODO remove this
    tout_saved = np.random.random_sample(
        (1440 * 30 +
         5 * 1440), ) + 60  #Only for testing that the indexing is done right
    count = 1440 * 30 + 1440
    #tout_saved = np.zeros(1440*365)

    #count = 1440*30 + 1440

    #setpoint_temp = 67

    ############################################################################################
    if count > 365 * 1440:  #keep the number of saved data points from being too large - can adjust if 1 year is too many
        tout_reset = np.zeros(1440 * 365)
        tout_reset[0:1440 * 30 - 1] = tout_saved[365 * 1440 - 30 * 1440:365 *
                                                 1440]
        tout_saved = tout_reset
        count = 1440 * 30 + 1  #starts at zero, count number represents the number of run about to happen adn sensor data just received

    #sensor data here to be removed once the data is read in
    tdb = 75  # dry-bulb air temperature, [$^{\circ}$C]
    tg = 76  #globe temperature
    rh = 50  # relative humidity, [%]
    tout = 40  #outdoor temperature
    occupancy = 1  #occupancy

    #formula to convert to Fahrenheit from Celsius
    #F = (Cx1.8) + 32

    #reset all error flags, needed all error variables in case more than one is true
    error_1 = ""
    error_2 = ""
    error_3 = ""
    error_4 = ""
    error_5 = ""

    if tdb <= 0 | tdb >= 110:  #test logic behind the measurements
        error_1 = "Malfunction indoor temp"

    if tdb <= 55 | tdb >= 90:
        error_2 = "Potential unsafe conditions"

    if rh < 0 | rh > 100:
        error_3 = "Malfunction rh"

    if tout < -50 | tout > 110:
        error_4 = "Malfunction outdoor temp"

    if tg <= 0 | tg >= 110:
        error_5 = "Malfunction gt"

    #clothing level prediction
    if tout >= 75:  #summer
        icl = 0.5  # clo_typical_ensembles('Typical summer indoor clothing') # calculate total clothing insulation
    if tout < 75 & tout >= 60:  #spring
        icl = 0.61  #clo_typical_ensembles('Trousers, long-sleeve sweatshirt')
    if tout < 60 & tout >= 45:  #fall
        icl = 0.74  #clo_typical_ensembles('Sweat pants, long-sleeve sweatshirt')
    if tout < 45:  #winter
        icl = 1.0  #clo_typical_ensembles('Typical winter indoor clothing')

    #imput from user - recieved from GUI
    activity = "moderately active"  #  "resting", "moderately active", "active"
    if activity == "resting":
        met = met_typical_tasks['Seated, quiet']
    if activity == "moderately active":
        met = met_typical_tasks['Walking about']
    if activity == "active":
        met = met_typical_tasks['Calisthenics']
        if tout < 50:
            clo = .5
        else:
            clo = 0.36  #workout clothes
    print(met)

    #Held Constant for residencies
    v = 0.1  # average air velocity, [m/s]

    #MRT Calculation
    tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)
    #operative temp calulation
    op = 0.5 * (tdb + tr)
    #print(op)

    # calculate the relative air velocity
    vr = v_relative(v=v, met=met)
    # calculate PMV in accordance with the ASHRAE 55 2017
    results = pmv_ppd(tdb=tdb,
                      tr=tr,
                      vr=vr,
                      rh=rh,
                      met=met,
                      clo=icl,
                      standard="ASHRAE",
                      units="IP")

    def get_first_key(dictionary):
        for key in dictionary:
            return key
        raise IndexError

    key1 = get_first_key(results)
    pmv = results[key1]

    #print(pmv)

    # print PMV value- this whole group can be eventually deleted
    print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

    if pmv <= float(0.5) and pmv >= float(-0.5):
        print('Acceptable!')

    if pmv >= 0.5:
        print('Too warm!Turn on fan')

    if pmv <= -0.5:
        print('Too cold! Turn on heater! or Grab Blanket')

    ##################################################################
    #finding the setpoints

    num_runs = count  #get this value from pipes
    print("Count:", count)
    if num_runs <= 1440 * 30:  #for when less than a months worth of data is collected
        t_running_mean = 45  #average temperature in March in Lexington, KY
        tout_saved[num_runs] = tout
    else:
        t_running_mean = sum(
            tout_saved[(num_runs - 30 * 1440):num_runs]) / (30 * 1440)
    print("Running mean:", t_running_mean)
    setpoints = adaptive_ashrae(tdb, tr, t_running_mean, v, units="IP")
    #print(setpoints)

    print(
        f"low={setpoints['tmp_cmf_90_low']}, high={setpoints['tmp_cmf_90_up']}%"
    )

    if pmv < -0.5 and pmv > 0.5:  #check if outside the comfortable range
        if occupancy == 1:
            #checking if the change fixed it summer
            PMV_bool = 0
            setpoint_low = setpoints['tmp_cmf_90_low']
            tg = tdb + 2  #can adjust this guess based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

            results_low = pmv_ppd(tdb=tdb,
                                  tr=tr,
                                  vr=vr,
                                  rh=rh,
                                  met=met,
                                  clo=icl,
                                  standard="ASHRAE",
                                  units="IP")
            print('Using low setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            setpoint_high = setpoints['tmp_cmf_90_up']
            tg = setpoint_high + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

            results_high = pmv_ppd(tdb=tdb,
                                   tr=tr,
                                   vr=vr,
                                   rh=rh,
                                   met=met,
                                   clo=icl,
                                   standard="ASHRAE",
                                   units="IP")
            print('Using high setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            tdb = (setpoints['tmp_cmf_90_up'] +
                   setpoints['tmp_cmf_90_low']) / 2
            tg = tdb + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)
            print('mid setpoint')
            print(tdb)

            results_mid = pmv_ppd(tdb=tdb,
                                  tr=tr,
                                  vr=vr,
                                  rh=rh,
                                  met=met,
                                  clo=icl,
                                  standard="ASHRAE",
                                  units="IP")
            print('Using mid setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            #want the set point closest to the middle neutral temperature for optimal comfort
            set_point_PMV = min(
                abs(0 - results_low), abs(0 - results_high),
                abs(0 - results_mid))  #this setpoint will be sent to Joseph

            #select the temperature that corresponds to the PMV setpoint
            if set_point_PMV == results_high:
                set_point_temp = setpoints['tmp_cmf_80_up']
            if set_point_PMV == results_mid:
                set_point_temp = (setpoints['tmp_cmf_80_up'] +
                                  setpoints['tmp_cmf_80_low']) / 2
            if set_point_PMV == results_low:
                set_point_temp = setpoints['tmp_cmf_80_low']

        if occupancy == 0:  #relaxed comfort parameters
            #checking if the change fixed it summer
            if pmv > 1 or pmv < -1:
                PMV_bool = 0
                setpoint_low = setpoints['tmp_cmf_80_low']
                tg = tdb + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
                tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

                results_low = pmv_ppd(tdb=tdb,
                                      tr=tr,
                                      vr=vr,
                                      rh=rh,
                                      met=met,
                                      clo=icl,
                                      standard="ASHRAE",
                                      units="IP")
                print('Using low setpoint')
                print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

                setpoint_high = setpoints['tmp_cmf_80_up']
                tg = setpoint_high + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
                tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

                results_high = pmv_ppd(tdb=tdb,
                                       tr=tr,
                                       vr=vr,
                                       rh=rh,
                                       met=met,
                                       clo=icl,
                                       standard="ASHRAE",
                                       units="IP")
                print('Using high setpoint')
                print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

                tdb = (setpoints['tmp_cmf_80_up'] +
                       setpoints['tmp_cmf_80_low']) / 2
                tg = tdb + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
                tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)
                print('mid setpoint')
                print(tdb)

                results_mid = pmv_ppd(tdb=tdb,
                                      tr=tr,
                                      vr=vr,
                                      rh=rh,
                                      met=met,
                                      clo=icl,
                                      standard="ASHRAE",
                                      units="IP")
                print('Using mid setpoint')
                print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

                if results_high < -1 or results_high > 1:
                    results_high = 0  #really low compared to the other options and wont be selected as it is an infeasible option

                if results_low < -1 or results_low > 1:
                    result_low = 0

                if results_mid < -1 or results_mid > 1:
                    results_mid = 0

                    #comparing the setpoints to select the one closest to the edge of the comfortable window to lead to maximum savings in energy costs
                set_point_PMV = max(
                    abs(0 - results_low), abs(0 - results_high),
                    abs(0 -
                        results_mid))  #this setpoint will be sent to Joseph

                #select the temperature that corresponds to the PMV setpoint
                if set_point_PMV == results_high:
                    set_point_temp = setpoints['tmp_cmf_80_up']
                if set_point_PMV == results_mid:
                    set_point_temp = (setpoints['tmp_cmf_80_up'] +
                                      setpoints['tmp_cmf_80_low']) / 2
                if set_point_PMV == results_low:
                    set_point_temp = setpoints['tmp_cmf_80_low']
            else:
                PMV_bool = 1
                setpoint_temp = setpoint_temp

    else:
        PMV_bool = 1
        if occupancy == 1:
            setpoint_temp = setpoint_temp  # keep the same setpoint if it is in the comfortable range no need to cause the hvac to turn on if it is comfortable
        else:  #allow the comfort conditions to relax to with the (-1 to 1 range)
            setpoint_low = setpoints['tmp_cmf_80_low']
            tg = tdb + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

            results_low = pmv_ppd(tdb=tdb,
                                  tr=tr,
                                  vr=vr,
                                  rh=rh,
                                  met=met,
                                  clo=icl,
                                  standard="ASHRAE",
                                  units="IP")
            print('Using low setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            setpoint_high = setpoints['tmp_cmf_80_up']
            tg = setpoint_high + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)

            results_high = pmv_ppd(tdb=tdb,
                                   tr=tr,
                                   vr=vr,
                                   rh=rh,
                                   met=met,
                                   clo=icl,
                                   standard="ASHRAE",
                                   units="IP")
            print('Using high setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            tdb = (setpoints['tmp_cmf_80_up'] +
                   setpoints['tmp_cmf_80_low']) / 2
            tg = tdb + 2  #can adjust based on how the gt in the fridge changes with the heating or cooling
            tr = t_mrt(tg, tdb, v, d=0.075, emissivity=0.95)
            print('mid setpoint')
            print(tdb)

            results_mid = pmv_ppd(tdb=tdb,
                                  tr=tr,
                                  vr=vr,
                                  rh=rh,
                                  met=met,
                                  clo=icl,
                                  standard="ASHRAE",
                                  units="IP")
            print('Using mid setpoint')
            print(f"pmv={results['pmv']}, ppd={results['ppd']}%")

            if results_high < -1 or results_high > 1:
                results_high = 0  #really low compared to the other options and wont be selected as it is an infeasible option

            if results_low < -1 or results_low > 1:
                result_low = 0

            if results_mid < -1 or results_mid > 1:
                results_mid = 0

            #comparing the setpoints to select the one closest to the edge of the comfortable window to lead to maximum savings in energy costs
            set_point_PMV = max(
                abs(0 - results_low), abs(0 - results_high),
                abs(0 - results_mid))  #this setpoint will be sent to Joseph

            #select the temperature that corresponds to the PMV setpoint
            if set_point_PMV == results_high:
                set_point_temp = setpoints['tmp_cmf_80_up']
            if set_point_PMV == results_mid:
                set_point_temp = (setpoints['tmp_cmf_80_up'] +
                                  setpoints['tmp_cmf_80_low']) / 2
            if set_point_PMV == results_low:
                set_point_temp = setpoints['tmp_cmf_80_low']

    count = count + 1

    #END###########################################
    return pmv, setpoint_temp
예제 #6
0
def PythonFunction():

    #model performance
    deltaT = 0.5
    orientation = 0  #0 for vertical panel, 1 for horizontal

    #Variables for multiple modes of heat transfer
    panel_height = 18  #[m]
    panel_width = 10  #[m]
    insulation_thicknes = 0.15  #[m]

    A_cs = panel_height * panel_width  #area of cold panel [m]
    P_cs = (panel_height * 2) + (panel_width * 2)  #perimeter of cold panel [m]

    #Variables for convective heat transfer
    S = 0.2  #characteristic length (distance between cold panel and film [m])

    E_window = 0.02  #emissivity of windows

    Cp = 4.184  #[KJ/Kg]

    T_air1 = TRNSYS.getInputValue(1)  #air temperature surrounding the panel
    RH1 = TRNSYS.getInputValue(2)  #relative humidity %
    DeHumid_Sched = TRNSYS.getInputValue(3)  #wind speed
    T_dewpoint1 = TRNSYS.getInputValue(4)

    T_wallN = TRNSYS.getInputValue(5)
    T_wallS = TRNSYS.getInputValue(6)
    T_wallE = TRNSYS.getInputValue(7)
    T_wallW = TRNSYS.getInputValue(8)
    T_wallF = TRNSYS.getInputValue(9)
    T_wallR = TRNSYS.getInputValue(10)

    T_inlet1 = TRNSYS.getInputValue(11)
    hot_side_flow_rate = TRNSYS.getInputValue(12)
    mass_flow_rate = (hot_side_flow_rate / (3600))  #[Kg/sec]
    Day_of_year = int(TRNSYS.getInputValue(13))
    Occ_Schedual_input = TRNSYS.getInputValue(14)
    Heatpump_temp_signal = TRNSYS.getInputValue(15)

    wind = 0.5

    err_inc = 1.0
    h_int_err = err_inc * 0.981474747
    h_ext_err = err_inc * 1.082080808
    em_cs_err = err_inc
    Trans_error = err_inc * 0.864969697
    T_cs_err = err_inc
    T_ss_err = err_inc * 1.013050505
    T_air_err = err_inc
    B_err = err_inc
    u_err = err_inc
    p_err = err_inc
    a_err = err_inc
    k_err_int = err_inc
    k_err_ext = err_inc * 1.039676768
    wind_err = err_inc
    n_err = 0.705393939

    # =============================================================================
    #     err_inc = 1.0
    #     h_int_err = err_inc
    #     h_ext_err = err_inc
    #     em_cs_err = err_inc
    #     Trans_error = err_inc
    #     #T_cs_err = err_inc
    #     T_ss_err = err_inc
    #     T_air_err = err_inc
    #     B_err = err_inc
    #     u_err = err_inc
    #     p_err = err_inc
    #     a_err = err_inc
    #     k_err_int = err_inc
    #     k_err_ext = err_inc
    #     #wind_err = err_inc
    # =============================================================================

    FTIR_out = FTIR()
    trans = FTIR_out[0]
    reflect = FTIR_out[1]
    wave_len2 = FTIR_out[2]

    trans = [(x * Trans_error) for x in trans]
    absorb = list(range(0, len(trans)))
    absorb = [(1 - trans[x] - reflect[x]) for x in absorb]

    T_air = (T_air1 *
             T_air_err) + 273.15  #air temperature surrounding the panel
    E_cs = 0.95 * em_cs_err  #emissivity of cold surface

    RH = RH1 / 100  #relative humidity to decimal

    #=================Step 0: End ============================================

    average_wall_temp = (T_wallN + T_wallS + T_wallE + T_wallW + T_wallF +
                         T_wallR) / 6

    path = r"D:\Masters related\Python Code\Daily_Temps\Singapore_ave_daily_temp.csv"
    file = open(path, newline='')
    reader = csv.reader(file)
    Ave_Temp = []
    header = next(reader)
    for row in reader:
        temp = float(row[0])
        Ave_Temp.append(temp)

    Trm = (Ave_Temp[Day_of_year - 2] + Ave_Temp[Day_of_year - 3] +
           Ave_Temp[Day_of_year - 4] + Ave_Temp[Day_of_year - 5] +
           Ave_Temp[Day_of_year - 6] + Ave_Temp[Day_of_year - 7] +
           Ave_Temp[Day_of_year -
                    8]) / 7  #running mean outdoor temp for adaptive model

    if Occ_Schedual_input == 1:
        x = 1
        #=====================Step 3: Calculate View Factors between panels and human============================================
        P1_Panel_toHumans_F = [0.00088, 0.00088, 0.00088, 0.00088, 0.0027]
        total_Panel_toHumans_F = 3 * sum(
            P1_Panel_toHumans_F) * Occ_Schedual_input
        ave_panel_toHumans = (
            total_Panel_toHumans_F /
            (3 * len(P1_Panel_toHumans_F))) * Occ_Schedual_input
        ave_human_toPanels_F = ((ave_panel_toHumans * A_cs) / 1.551)

        #===========================Step 3: End ======================================================================

        #=================Step 1: Calculate MRT as seen by Panel ============================================

        #with people
        T_wall1 = Panel_MRT(T_wallF, T_wallN, T_wallS, T_wallE, T_wallW,
                            E_window, total_Panel_toHumans_F)  #MRT in room
        P1_T_wall = (T_wall1 * T_ss_err) + 273.15  #MRT in room

        #without people
        T_wall1_no_H = Panel_MRT(T_wallF, T_wallN, T_wallS, T_wallE, T_wallW,
                                 E_window, 0)  #MRT in room
        P1_T_wall_no_H = (T_wall1_no_H * T_ss_err) + 273.15  #MRT in room

        #=================Step 1: End ======================================================================

        #u_val = (3*(insulation_thicknes**2))-(1.82*insulation_thicknes)+0.34 #[W/m^2-k]

        Panel1_model1 = film_temp_and_Q(
            orientation, panel_height, panel_width, S, A_cs, P_cs, deltaT,
            10 + 273.15, P1_T_wall, T_air, RH, E_cs, wind, trans, reflect,
            absorb, wave_len2, h_int_err, h_ext_err, B_err, u_err, p_err,
            a_err, k_err_ext, k_err_int, n_err)
        #Panel1_model1_Qdot_throughins = (u_val*A_cs*(T_wallR-15))/1000
        Panel1_model1_Q = (Panel1_model1[0] + Panel1_model1[4]) / 1000
        t1_in = 10 - (Panel1_model1_Q / (2 * mass_flow_rate * Cp))
        Panel1_model2 = film_temp_and_Q(
            orientation, panel_height, panel_width, S, A_cs, P_cs, deltaT,
            5 + 273.15, P1_T_wall, T_air, RH, E_cs, wind, trans, reflect,
            absorb, wave_len2, h_int_err, h_ext_err, B_err, u_err, p_err,
            a_err, k_err_ext, k_err_int, n_err)
        #Panel1_model2_Qdot_throughins = (u_val*A_cs*(T_wallR-10))/1000
        Panel1_model2_Q = (Panel1_model2[0] + Panel1_model2[4]) / 1000
        t2_in = 5 - (Panel1_model2_Q / (2 * mass_flow_rate * Cp))

        P1_T_inlet_t_cs_equ = linear_regression(t1_in, 10, t2_in, 5)

        #=================Step 2:Calculate Heat Transfer between Panel and Empty Room ============================================

        P1_T_cs1 = (P1_T_inlet_t_cs_equ[0] * T_inlet1) + P1_T_inlet_t_cs_equ[1]
        P1_T_cs = P1_T_cs1 + 273.15
        FTaQ_results = film_temp_and_Q(
            orientation, panel_height, panel_width, S, A_cs, P_cs, deltaT,
            P1_T_cs, P1_T_wall_no_H, T_air, RH, E_cs, wind, trans, reflect,
            absorb, wave_len2, h_int_err, h_ext_err, B_err, u_err, p_err,
            a_err, k_err_ext, k_err_int, n_err)
        P1_Q_Panel_empty_room1 = FTaQ_results[0]
        P1_Q_film_room = FTaQ_results[4]

        P1_Q_room_gain = P1_Q_Panel_empty_room1 * (1 - total_Panel_toHumans_F)

        #=================Step 2: End ======================================================================

        #=================Step 4:Calculate Heat Transfer between Panel and Human ==================================

        P1_Q_PanelHuman_results = film_temp_and_Q(
            orientation, panel_height, panel_width, S, A_cs, P_cs, deltaT,
            P1_T_cs, P1_T_wall, T_air, RH, E_cs, wind, trans, reflect, absorb,
            wave_len2, h_int_err, h_ext_err, B_err, u_err, p_err, a_err,
            k_err_ext, k_err_int, n_err)
        P1_Q_PanelOut = P1_Q_PanelHuman_results[2]
        P1_T_film1 = FTaQ_results[1] - 273.15

        #=================Step 4: End ======================================================================

        #=================Step 5 & 6: Calculate MRT as seen by human and pmv============================================

        H_MRT = list(range(5))
        adapt_result_low = list(range(5))
        adapt_result_up = list(range(5))
        #adapt_result_temp = list(range(5))
        panel_MRT_temp = list(range(5))
        Q_human_panel = list(range(5))

        for x in H_MRT:
            H_MRT_results = MRT_Human(P1_Panel_toHumans_F[x], P1_Q_PanelOut,
                                      T_wallN, T_wallS, T_wallE, T_wallW,
                                      T_wallF, T_wallR, A_cs, E_window)
            H_MRT[x] = H_MRT_results[0]
            panel_MRT_temp[x] = H_MRT_results[2]
            adapt_resulttemp = adaptive_ashrae(T_air1, H_MRT[x], Trm, wind)
            adapt_result_low[x] = adapt_resulttemp['tmp_cmf_90_low']
            adapt_result_up[x] = adapt_resulttemp['tmp_cmf_90_up']
            #adapt_result_temp[x] = adapt_resulttemp['tmp_cmf']
            Q_human_panel[x] = H_MRT_results[3] * P1_Panel_toHumans_F[x]

        ADAPT_MIN = max(adapt_result_low)
        ADAPT_MAX = min(adapt_result_up)
        #ADAPT_temp_goal = sum(adapt_result_temp)/len(adapt_result_temp)

        max_HUMAN_MRT = max(H_MRT)
        AVE_HUMAN_MRT = sum(H_MRT) / len(H_MRT)
        Panel_MRT_Temp = sum(panel_MRT_temp) / len(panel_MRT_temp)

        AVE_Q_human_panel = sum(Q_human_panel) / len(Q_human_panel)

        operative_temp = t_o(T_air1, max_HUMAN_MRT, wind)

        #=================Step 5 & 6: End ======================================================================

        #=================Step 7:Update cold surface temperature============================================

        P1_T_outlet1 = P1_T_cs1 + (P1_T_cs1 - T_inlet1)
        T_outlet1_ave = P1_T_outlet1
        T_film1_low = P1_T_film1

        water_heat_gain_rate = 1000 * mass_flow_rate * Cp * (P1_T_outlet1 -
                                                             T_inlet1)

        rad_control = 1
        heatpump_divert_control = 0.5

        panelflow_cont_var = (P1_T_outlet1 - (T_inlet1 + 0.5)) * 100

        # =============================================================================
        #         if  T_dewpoint1 <15:
        #             T_dewpoint1 = 15
        # =============================================================================

        T_cs_results = CS_temp(orientation, panel_height, panel_width, S, A_cs,
                               P_cs, deltaT, T_dewpoint1 + 273.15, P1_T_wall,
                               T_air, RH, E_cs, wind, trans, reflect, absorb,
                               wave_len2, h_int_err, h_ext_err, B_err, u_err,
                               p_err, a_err, k_err_ext, k_err_int, n_err)
        Panel_inlet_temp_set = (T_cs_results[1] + 2) - 273.15

        #=================Step 7:End============================================

# =============================================================================
#         ##Leave for Debugging
#         rad_control = 0
#         operative_temp = 20
#         AVE_HUMAN_MRT = 30
#         P1_Q_room_gain = 0
#         panelflow_cont_var = 0
#         P1_Q_film_room = 0
#         ADAPT_MIN = 0
#         P1_T_outlet1 = T_inlet1
#         P2_T_outlet1 = T_inlet1
#         T_outlet1_ave = T_inlet1
#         P1_T_cs1 = T_inlet1
#         T_film1_low = 0
#         ave_human_toPanels_F = 0
#         controlled_variable = 0
#         heatpump_divert_control = 0.5
#         Panel_MRT_Temp = 2532
#         Panel_inlet_temp_set = 25
#         ADAPT_MAX = 1
#         PMV_MIN = 1
#         PMV_MAX = 1
# =============================================================================

    if Occ_Schedual_input == 0:

        ADAPT_MIN = 0
        ADAPT_MAX = 0
        AVE_HUMAN_MRT = 0
        rad_control = 0
        P1_Q_room_gain = 0
        P1_Q_film_room = 0
        P1_T_outlet1 = T_inlet1
        T_outlet1_ave = T_inlet1
        P1_T_cs1 = T_inlet1
        T_film1_low = 0
        ave_human_toPanels_F = 0
        panelflow_cont_var = (P1_T_outlet1 - (T_inlet1 + 0.5)) * 100
        heatpump_divert_control = 1
        Panel_inlet_temp_set = 20
        Panel_MRT_Temp = 0
        operative_temp = 0
        water_heat_gain_rate = 0
        AVE_Q_human_panel = 0

    ##########


# =============================================================================
#     P1_Q_room_gain = 0
#     P1_Q_film_room = 0
# =============================================================================
##########

    ignore = 0

    TRNSYS.setOutputValue(1, P1_Q_room_gain)
    TRNSYS.setOutputValue(2, P1_T_outlet1)
    TRNSYS.setOutputValue(3, rad_control)
    TRNSYS.setOutputValue(4, wind)
    TRNSYS.setOutputValue(5, T_inlet1)
    TRNSYS.setOutputValue(6, P1_T_cs1)
    TRNSYS.setOutputValue(7, operative_temp)
    TRNSYS.setOutputValue(8, T_film1_low)
    TRNSYS.setOutputValue(9, T_dewpoint1)
    TRNSYS.setOutputValue(10, P1_Q_film_room)
    TRNSYS.setOutputValue(11, Trm)
    TRNSYS.setOutputValue(12, ave_human_toPanels_F)
    TRNSYS.setOutputValue(13, panelflow_cont_var)
    TRNSYS.setOutputValue(14, AVE_Q_human_panel)
    TRNSYS.setOutputValue(15, ignore)
    TRNSYS.setOutputValue(16, ignore)
    TRNSYS.setOutputValue(17, ADAPT_MIN)
    TRNSYS.setOutputValue(18, ADAPT_MAX)
    TRNSYS.setOutputValue(19, average_wall_temp)
    TRNSYS.setOutputValue(20, water_heat_gain_rate)
    TRNSYS.setOutputValue(21, heatpump_divert_control)
    TRNSYS.setOutputValue(22, Panel_MRT_Temp)
    TRNSYS.setOutputValue(23, Panel_inlet_temp_set)
    TRNSYS.setOutputValue(24, AVE_HUMAN_MRT)

    # =============================================================================
    #   Not official
    #     P1_Panel_toHumans_F = [0.00088, 0.00088, 0.00088, 0.00088, 0.0028]
    #     total_Panel_toHumans_F = sum(P1_Panel_toHumans_F)*Occ_Schedual_input
    #     ave_panel_toHumans = (total_Panel_toHumans_F/len(P1_Panel_toHumans_F))*Occ_Schedual_input
    #     ave_human_toPanels_F = ((ave_panel_toHumans*A_cs)/1.551)
    #
    #
    #
    #
    #
    #     if DeHumid_Sched == 1:
    #          if RH1 >= 60:
    #              AC_flow = 700
    #          if 58 < RH1 < 60:
    #              AC_flow = 400
    #          if  RH1 <= 58:
    #              AC_flow = 300
    #
    #
    #
    #     elif DeHumid_Sched == 0:
    #              AC_flow = 50
    #
    #
    #
    #     TRNSYS.setOutputValue(1,abs(0))
    #     TRNSYS.setOutputValue(2,0)
    #     TRNSYS.setOutputValue(3,0)
    #     TRNSYS.setOutputValue(4,0)
    #     TRNSYS.setOutputValue(5,0)
    #     TRNSYS.setOutputValue(6,0)
    #     TRNSYS.setOutputValue(7,0)
    #     TRNSYS.setOutputValue(8,0)
    #     TRNSYS.setOutputValue(9,0)
    #     TRNSYS.setOutputValue(10,abs(0))
    #     TRNSYS.setOutputValue(11,0)
    #     TRNSYS.setOutputValue(12,ave_human_toPanels_F)
    #     TRNSYS.setOutputValue(13,0)
    #     TRNSYS.setOutputValue(14,0)
    #     TRNSYS.setOutputValue(15,0)
    #     TRNSYS.setOutputValue(16,abs(0))
    #     TRNSYS.setOutputValue(17,0)
    #     TRNSYS.setOutputValue(18,0)
    #     TRNSYS.setOutputValue(19,0)
    #     TRNSYS.setOutputValue(20, AC_flow)
    #     TRNSYS.setOutputValue(21, 0)
    #     TRNSYS.setOutputValue(22, 0)
    #     TRNSYS.setOutputValue(23, 0)
    #     TRNSYS.setOutputValue(24, 0)
    # =============================================================================
    return