From 86a4c4feea1d9cd1151ed4823a856718af2e10fc Mon Sep 17 00:00:00 2001 From: FedericoTartarini Date: Fri, 17 Jan 2020 15:08:37 +0800 Subject: [PATCH 1/3] now user can export that results of the calculations in 4 .txt file. These data can be then processed using the Python code in process_data_ashrae.py to generate the tables for the ASHRAE standard. This functionality is disabled by default but it can be activated by setting output_data_for_ASHRAE_table = true --- ASHRAE 55 Tables/mrt inputs | 142 ++++++++++++++++++++++++ ASHRAE 55 Tables/process_data_ashrae.py | 94 ++++++++++++++++ index.html | 2 +- js/main.js | 53 +++++++-- js/mrt.js | 3 +- 5 files changed, 283 insertions(+), 11 deletions(-) create mode 100644 ASHRAE 55 Tables/mrt inputs create mode 100644 ASHRAE 55 Tables/process_data_ashrae.py diff --git a/ASHRAE 55 Tables/mrt inputs b/ASHRAE 55 Tables/mrt inputs new file mode 100644 index 0000000..024b0e6 --- /dev/null +++ b/ASHRAE 55 Tables/mrt inputs @@ -0,0 +1,142 @@ +// default values +mrt.room.depth = 30 +mrt.room.width = 15 +mrt.room.height= 3.5 +params.wall1.temperature = 25 +params.wall1.emissivity = 0.9 +params.wall1.panel.window = true +params.wall1.panel.active = true +params.wall1.panel.emissivity = 0.9 +params.wall1.panel.height = 3 +params.wall1.panel.width = 13 +params.wall1.panel.xposition = 1 +params.wall1.panel.yposition = 0.1 +params.wall2.temperature = 25 +params.wall2.emissivity = 0.9 +params.wall3.temperature = 25 +params.wall3.emissivity = 0.9 +params.wall4.temperature = 25 +params.wall4.emissivity = 0.9 +params.ceiling.temperature = 25 +params.ceiling.emissivity = 0.9 +params.floor.temperature = 25 +params.floor.emissivity = 0.9 +comfort.ta = 25 +comfort.vel = 0.1 +comfort.rh = 50 +comfort.met = 1.1 +comfort.clo= 0.55 +solarcal.asa = 0.84 +solarcal.Idir = 900 +solarcal.az = 270 +mrt.occupant.azimuth = 0 +params.display = "PMV" + +// 13 reference line in the EXCEL sheet +solarcal.fbes = 0.5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.016 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 14 +solarcal.fbes = 0.5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.03 +params.wall1.panel.temperature = 35 +calculate_all(true) // this line performs the calculations + +// 15 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.001 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 16 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.015 +params.wall1.panel.temperature = 35 +calculate_all(true) // this line performs the calculations + +// 18 +solarcal.fbes = .5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.008 +params.wall1.panel.temperature = 48 +calculate_all(true) // this line performs the calculations + +// 19 +solarcal.fbes = .5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.008 +params.wall1.panel.temperature = 55 +calculate_all(true) // this line performs the calculations + +// 20 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.008 +params.wall1.panel.temperature = 48 +calculate_all(true) // this line performs the calculations + +// 21 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.008 +params.wall1.panel.temperature = 55 +calculate_all(true) // this line performs the calculations + +// 23 +solarcal.fbes = .5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.008 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 24 +solarcal.fbes = .5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.001 +params.wall1.panel.temperature = 40 +calculate_all(true) // this line performs the calculations + +// 25 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.001 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 26 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.001 +params.wall1.panel.temperature = 40 +calculate_all(true) // this line performs the calculations + +// 28 +solarcal.fbes = .5 +mrt.occupant.posture = "seated" +solarcal.alt = 50 +params.wall1.panel.tsol = 0.15 +params.wall1.panel.temperature = 35 +calculate_all(true) // this line performs the calculations + + + + + diff --git a/ASHRAE 55 Tables/process_data_ashrae.py b/ASHRAE 55 Tables/process_data_ashrae.py new file mode 100644 index 0000000..0d6be80 --- /dev/null +++ b/ASHRAE 55 Tables/process_data_ashrae.py @@ -0,0 +1,94 @@ +""" +This code is used to calculate the values for the ASHREA 55 2017 standard. +This code uses as input the results from the MRT tool. In order to enable this feature, please set the variable output_data_for_ASHRAE_table to true. +Each time the code will run the MRT will output four files, each containing the following parameters: x, y, z (coordinates) and results of calculations (e.g. PMV) +The files will generally be saved automatically in the download folder. Copy and paste them in the directory ASHRAE 55 Tables/Output_MRT_tool. +Then run the code below + +@author Federico Tartarini +""" + +import pandas as pd +import glob +import os +import matplotlib.pyplot as plt +from pprint import pprint + + +def interpolation(data_frame, value=7.5, axis='x', variable='PMV'): + """This functions interpolates between two array, it is used to calculate the value of PMV in the center of the room""" + unique_values = data_frame[axis].unique() # get the coordinates in the axis + upper = [x for x in unique_values if x > value][0] # find the closest values to the one selected + lower = [x for x in unique_values if x < value][-1] + array_upper = data_frame.loc[data_frame[axis] == upper, variable] # extract the two arrays that will be used to calculate the interpolated values + array_lower = data_frame.loc[data_frame[axis] == lower, variable] + result = [] + for y_low, y_up in zip(array_lower, array_upper): + result.append((value - upper) / (lower - upper) * (y_low - y_up) + y_up) + + return result # return results of interpolation + + +plt.close('all') + +# directory containing input files +dir_files = os.path.join(os.getcwd(), 'ASHRAE 55 Tables', 'Output MRT tool') +variable_of_interest = 'PMV' +axis_along_which_window_is_installed = 'x' +center_of_the_wall = 7.5 # value in meters + +# check how many calculaitons where performed, for each set of input 4 files are outputted by the code +runs = [] +for file in glob.glob(os.path.join(dir_files, "*.txt")): + runs.append(file.split('_', 2)[2].split('.txt')[0]) +runs = set(runs) + +# store all the results in one single Pandas data frame +df_runs = pd.DataFrame() +for run in runs: + df_run = pd.DataFrame() + for ix, file in enumerate(glob.glob(os.path.join(dir_files, f"*{run}.txt"))): + df = pd.read_csv(os.path.join(dir_files, file), sep=',', header=None).transpose() + if ix == 0: + df_run[file.split('_')[1]] = df.values[:, 0] + else: + df_run[file.split('_')[1]] = df.values + + df_run['Run'] = file.split('_', 2)[2].split('.txt')[0] + df_runs = df_runs.append(df_run) + +# plt the results and calculate the minimum distance from the window. this value is calculated in the center of the room +cm = plt.cm.get_cmap('RdYlBu_r') +results = dict() +for run in runs: + df_results = pd.DataFrame() + df_run = df_runs[df_runs.Run == run] + + df_results[variable_of_interest] = interpolation(df_run, value=center_of_the_wall, axis=axis_along_which_window_is_installed, variable=variable_of_interest) + df_results['distance'] = df_run.z.unique() + df_results['x'] = center_of_the_wall + + plt.figure() + sc = plt.scatter(x=df_run.x, y=df_run.z, c=df_run.PMV, cmap=cm, vmin=0.501, vmax=0.7, marker='s', s=150) + plt.scatter(x=df_results['x'], y=df_results['distance'], c=df_results[variable_of_interest], cmap=cm, vmin=0.5, vmax=0.7, marker='s', s=150) + plt.ylim(0, 5) + plt.colorbar(sc, extend='both') + plt.title(run) + plt.savefig(os.path.join(os.getcwd(), 'ASHRAE 55 Tables', 'Figures', f'{run}.png'), dpi=300) + plt.close('all') + + # calculate the min distance from the wall + min_distance = df_results.loc[df_results[variable_of_interest] <= 0.5, 'distance'].min() + results[run] = round(min_distance, 2) + +pprint(results) + +# save results in a cvs +df_min_distances = pd.DataFrame([results]).T.reset_index() +df_min_distances['fbes'] = df_min_distances['index'].str.split('_', expand=True)[1] +df_min_distances['posture'] = df_min_distances['index'].str.split('_', expand=True)[3] +df_min_distances['winTemp'] = df_min_distances['index'].str.split('_', expand=True)[5] +df_min_distances['tsol'] = df_min_distances['index'].str.split('_', expand=True)[7] +df_min_distances.drop(columns=['index'], inplace=True) +df_min_distances.rename(columns={0: 'Min Distance [m]'}, inplace=True) +df_min_distances.to_csv('results_min_distances.csv', index=False) diff --git a/index.html b/index.html index 186a8d2..50ccd9b 100644 --- a/index.html +++ b/index.html @@ -107,7 +107,7 @@ - +
diff --git a/js/main.js b/js/main.js index 5f8b3a2..3c408bc 100644 --- a/js/main.js +++ b/js/main.js @@ -1,3 +1,4 @@ +var output_data_for_ASHRAE_table = false; // by setting this variable to true the code automatically downloads the results of the calculation to a csv file so can be used later on to generate the tables for the ASHRAE 55 standard var container; var camera, scene, renderer, raycaster, projector, INTERSECTED, directionalLight; var surfaces = []; @@ -112,7 +113,7 @@ params = { 'autoscale': true, 'scaleMin': 20.0, 'scaleMax': 40.0, - 'setGlobalSurfaceTemp': 21, + 'setGlobalSurfaceTemp': 21, 'update': function(){ document.getElementById('calculating').style.display = ""; setTimeout(function() { @@ -1088,7 +1089,7 @@ function init() { .onFinishChange(function(){ do_fast_stuff(); }); gui.add(params, 'setGlobalSurfaceTemp').min(tempMin).max(tempMax).step(1) - .onFinishChange(function(){ link_temps(); }); + .onFinishChange(function(){ link_temps(); }); gui.add(params, 'update'); @@ -1123,7 +1124,7 @@ function init() { panel_floor_xpos.max(mrt.room.width - 2* panelBorderMin); panel_floor_ypos.max(mrt.room.depth - 2* panelBorderMin); }; - + function link_temps(){ params.wall1.temperature = params.setGlobalSurfaceTemp; set_surface_property('wall1', 'temperature', params.wall1.temperature, false); @@ -1139,15 +1140,15 @@ function init() { set_surface_property('ceiling', 'temperature', params.ceiling.temperature, false); params.floor.temperature = params.setGlobalSurfaceTemp; set_surface_property('floor', 'temperature', params.floor.temperature, false); - + //update gui displays to match values stored in fields _.each([f_wall1, f_wall2, f_wall3, f_wall4, f_floor, f_ceiling], function(g){ g.updateDisplay(); }); - - do_fast_stuff(); + + do_fast_stuff(); } - + // Lights var ambientLight = new THREE.AmbientLight( 0x999999 ); scene.add( ambientLight ); @@ -1320,6 +1321,11 @@ function render() { function update_view_factors(){ + // arrays that will be used to store the coordinates output_data_for_ASHRAE_table is set to true + let x_location = []; + let y_location = []; + let z_location = []; + view_factors = _.map(plane.geometry.vertices, function(v){ var my_vector = new THREE.Vector3(); my_vector.copy(v); @@ -1335,8 +1341,32 @@ function update_view_factors(){ for (var i = 0; i < vfs.length; i++){ vfs[i].view_factor *= norm_factor; } + if (output_data_for_ASHRAE_table) { + x_location.push(my_vector.x); + y_location.push(my_vector.y); + z_location.push(my_vector.z); + } return vfs; }); + + if (output_data_for_ASHRAE_table) { + var link = document.createElement('a'); + link.setAttribute('href', 'data:text/plain,' + x_location.join(', ')); + let fileName = 'location_x_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; + link.setAttribute('download', fileName); + link.click(); + var link = document.createElement('a'); + link.setAttribute('href', 'data:text/plain,' + y_location.join(', ')); + fileName = 'location_y_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; + link.setAttribute('download', fileName); + link.click(); + var link = document.createElement('a'); + link.setAttribute('href', 'data:text/plain,' + z_location.join(', ')); + fileName = 'location_z_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; + link.setAttribute('download', fileName); + link.click(); + } + view_factors_need_updating = false; } @@ -1442,7 +1472,6 @@ function calculate_erf_point(v, skydome_center, window_objects, window_object_vf } function update_visualization(){ - if (view_factors_need_updating) { var vertex_colors = _.map(view_factors, function(){ return new THREE.Color(1, 1, 1); @@ -1517,5 +1546,13 @@ function update_visualization(){ f.vertexColors.push( vertex_colors[ idx ] ); } } + + if (output_data_for_ASHRAE_table) { + var link = document.createElement('a'); + link.setAttribute('href', 'data:text/plain,' + vertex_values.join(', ')); + const fileName = 'value_' + params.display + '_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; + link.setAttribute('download', fileName); + link.click(); + } plane.geometry.colorsNeedUpdate = true; } diff --git a/js/mrt.js b/js/mrt.js index 9c79ec5..a5ae81c 100644 --- a/js/mrt.js +++ b/js/mrt.js @@ -164,7 +164,7 @@ mrt.mesh_view_factor = function(mesh, d_perp, area, person_pos, person_az, postu var dvf = mrt.fanger_view_factor(p, d_perp, area, person_pos, person_az, posture); view_factor += dvf; } - } + } return view_factor; }; @@ -335,7 +335,6 @@ mrt.calc = function(surface_vfs){ my_mrt /= vf_emis_total; my_mrt = Math.pow(my_mrt, 0.25); my_mrt -= 273.15; - return my_mrt; }; From ac703dd5410edcb3395da1e1ebae1c3f6518a3fa Mon Sep 17 00:00:00 2001 From: FedericoTartarini Date: Wed, 29 Jan 2020 11:44:14 +0800 Subject: [PATCH 2/3] rounding to the second decimal when displaying results --- ASHRAE 55 Tables/mrt inputs | 50 +++++++++++++++++++++++++ ASHRAE 55 Tables/process_data_ashrae.py | 19 +++++++++- js/main.js | 4 +- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/ASHRAE 55 Tables/mrt inputs b/ASHRAE 55 Tables/mrt inputs index 024b0e6..3404e42 100644 --- a/ASHRAE 55 Tables/mrt inputs +++ b/ASHRAE 55 Tables/mrt inputs @@ -136,6 +136,56 @@ params.wall1.panel.tsol = 0.15 params.wall1.panel.temperature = 35 calculate_all(true) // this line performs the calculations +// 29 +solarcal.fbes = 0.5 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.005 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 30 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.005 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 31 +solarcal.fbes = 0.5 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.03 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 32 +solarcal.fbes = 1 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.03 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 33 +solarcal.fbes = 0.5 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.06 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + +// 34 +solarcal.fbes = 0.5 +mrt.occupant.posture = "standing" +solarcal.alt = 30 +params.wall1.panel.tsol = 0.09 +params.wall1.panel.temperature = 38 +calculate_all(true) // this line performs the calculations + + + diff --git a/ASHRAE 55 Tables/process_data_ashrae.py b/ASHRAE 55 Tables/process_data_ashrae.py index 0d6be80..d4cfe80 100644 --- a/ASHRAE 55 Tables/process_data_ashrae.py +++ b/ASHRAE 55 Tables/process_data_ashrae.py @@ -13,6 +13,7 @@ import os import matplotlib.pyplot as plt from pprint import pprint +import numpy as np def interpolation(data_frame, value=7.5, axis='x', variable='PMV'): @@ -29,6 +30,22 @@ def interpolation(data_frame, value=7.5, axis='x', variable='PMV'): return result # return results of interpolation +def find_min_distance(data_frame, value=0.5, axis='distance', variable='PMV'): + """This functions finds the minimum distance from the window by interpolating between values exported from MRT tool""" + unique_values = data_frame[variable].unique() # get the coordinates in the axis + upper = [x for x in unique_values if x > value][0] # find the closest values to the one selected + lower = [x for x in unique_values if x < value][-1] + closest_distance = data_frame.loc[data_frame[variable] == upper, axis].values[0] + further_distance = data_frame.loc[data_frame[variable] == lower, axis].values[0] + array_distances = np.linspace(closest_distance, further_distance, 100) + result = [] + for distance in array_distances: + result.append([distance, (distance - closest_distance) / (further_distance - closest_distance) * (lower - upper) + upper]) + + _ = pd.DataFrame(result, columns=[axis, variable]) + return _.loc[_[variable] <= 0.5, axis].min() # return results of interpolation + + plt.close('all') # directory containing input files @@ -78,7 +95,7 @@ def interpolation(data_frame, value=7.5, axis='x', variable='PMV'): plt.close('all') # calculate the min distance from the wall - min_distance = df_results.loc[df_results[variable_of_interest] <= 0.5, 'distance'].min() + min_distance = find_min_distance(df_results, value=0.5, axis='distance', variable='PMV') results[run] = round(min_distance, 2) pprint(results) diff --git a/js/main.js b/js/main.js index 3c408bc..7e66f5d 100644 --- a/js/main.js +++ b/js/main.js @@ -1305,9 +1305,9 @@ function render() { display_value = my_pmv.pmv; } document.getElementById('occupant-position').innerHTML = "Occupant (x, y): (" - + intersects[0].point.x.toFixed(1) + ", " + intersects[0].point.z.toFixed(1) + ")"; + + intersects[0].point.x.toFixed(2) + ", " + intersects[0].point.z.toFixed(2) + ")"; document.getElementById('cursor-temperature').innerHTML = params.display + ": " - + display_value.toFixed(1); + + display_value.toFixed(2); } else { document.getElementById('cursor-temperature').innerHTML = ""; document.getElementById('occupant-position').innerHTML = ""; From b4d19938cb7d927d163778fc93714a91cb4f6440 Mon Sep 17 00:00:00 2001 From: FedericoTartarini Date: Fri, 31 Jan 2020 09:25:58 +0800 Subject: [PATCH 3/3] removed data export functions and python code --- ASHRAE 55 Tables/mrt inputs | 192 ------------------------ ASHRAE 55 Tables/process_data_ashrae.py | 111 -------------- js/main.js | 36 ----- 3 files changed, 339 deletions(-) delete mode 100644 ASHRAE 55 Tables/mrt inputs delete mode 100644 ASHRAE 55 Tables/process_data_ashrae.py diff --git a/ASHRAE 55 Tables/mrt inputs b/ASHRAE 55 Tables/mrt inputs deleted file mode 100644 index 3404e42..0000000 --- a/ASHRAE 55 Tables/mrt inputs +++ /dev/null @@ -1,192 +0,0 @@ -// default values -mrt.room.depth = 30 -mrt.room.width = 15 -mrt.room.height= 3.5 -params.wall1.temperature = 25 -params.wall1.emissivity = 0.9 -params.wall1.panel.window = true -params.wall1.panel.active = true -params.wall1.panel.emissivity = 0.9 -params.wall1.panel.height = 3 -params.wall1.panel.width = 13 -params.wall1.panel.xposition = 1 -params.wall1.panel.yposition = 0.1 -params.wall2.temperature = 25 -params.wall2.emissivity = 0.9 -params.wall3.temperature = 25 -params.wall3.emissivity = 0.9 -params.wall4.temperature = 25 -params.wall4.emissivity = 0.9 -params.ceiling.temperature = 25 -params.ceiling.emissivity = 0.9 -params.floor.temperature = 25 -params.floor.emissivity = 0.9 -comfort.ta = 25 -comfort.vel = 0.1 -comfort.rh = 50 -comfort.met = 1.1 -comfort.clo= 0.55 -solarcal.asa = 0.84 -solarcal.Idir = 900 -solarcal.az = 270 -mrt.occupant.azimuth = 0 -params.display = "PMV" - -// 13 reference line in the EXCEL sheet -solarcal.fbes = 0.5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.016 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 14 -solarcal.fbes = 0.5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.03 -params.wall1.panel.temperature = 35 -calculate_all(true) // this line performs the calculations - -// 15 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.001 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 16 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.015 -params.wall1.panel.temperature = 35 -calculate_all(true) // this line performs the calculations - -// 18 -solarcal.fbes = .5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.008 -params.wall1.panel.temperature = 48 -calculate_all(true) // this line performs the calculations - -// 19 -solarcal.fbes = .5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.008 -params.wall1.panel.temperature = 55 -calculate_all(true) // this line performs the calculations - -// 20 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.008 -params.wall1.panel.temperature = 48 -calculate_all(true) // this line performs the calculations - -// 21 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.008 -params.wall1.panel.temperature = 55 -calculate_all(true) // this line performs the calculations - -// 23 -solarcal.fbes = .5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.008 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 24 -solarcal.fbes = .5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.001 -params.wall1.panel.temperature = 40 -calculate_all(true) // this line performs the calculations - -// 25 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.001 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 26 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.001 -params.wall1.panel.temperature = 40 -calculate_all(true) // this line performs the calculations - -// 28 -solarcal.fbes = .5 -mrt.occupant.posture = "seated" -solarcal.alt = 50 -params.wall1.panel.tsol = 0.15 -params.wall1.panel.temperature = 35 -calculate_all(true) // this line performs the calculations - -// 29 -solarcal.fbes = 0.5 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.005 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 30 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.005 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 31 -solarcal.fbes = 0.5 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.03 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 32 -solarcal.fbes = 1 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.03 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 33 -solarcal.fbes = 0.5 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.06 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - -// 34 -solarcal.fbes = 0.5 -mrt.occupant.posture = "standing" -solarcal.alt = 30 -params.wall1.panel.tsol = 0.09 -params.wall1.panel.temperature = 38 -calculate_all(true) // this line performs the calculations - - - - - - - diff --git a/ASHRAE 55 Tables/process_data_ashrae.py b/ASHRAE 55 Tables/process_data_ashrae.py deleted file mode 100644 index d4cfe80..0000000 --- a/ASHRAE 55 Tables/process_data_ashrae.py +++ /dev/null @@ -1,111 +0,0 @@ -""" -This code is used to calculate the values for the ASHREA 55 2017 standard. -This code uses as input the results from the MRT tool. In order to enable this feature, please set the variable output_data_for_ASHRAE_table to true. -Each time the code will run the MRT will output four files, each containing the following parameters: x, y, z (coordinates) and results of calculations (e.g. PMV) -The files will generally be saved automatically in the download folder. Copy and paste them in the directory ASHRAE 55 Tables/Output_MRT_tool. -Then run the code below - -@author Federico Tartarini -""" - -import pandas as pd -import glob -import os -import matplotlib.pyplot as plt -from pprint import pprint -import numpy as np - - -def interpolation(data_frame, value=7.5, axis='x', variable='PMV'): - """This functions interpolates between two array, it is used to calculate the value of PMV in the center of the room""" - unique_values = data_frame[axis].unique() # get the coordinates in the axis - upper = [x for x in unique_values if x > value][0] # find the closest values to the one selected - lower = [x for x in unique_values if x < value][-1] - array_upper = data_frame.loc[data_frame[axis] == upper, variable] # extract the two arrays that will be used to calculate the interpolated values - array_lower = data_frame.loc[data_frame[axis] == lower, variable] - result = [] - for y_low, y_up in zip(array_lower, array_upper): - result.append((value - upper) / (lower - upper) * (y_low - y_up) + y_up) - - return result # return results of interpolation - - -def find_min_distance(data_frame, value=0.5, axis='distance', variable='PMV'): - """This functions finds the minimum distance from the window by interpolating between values exported from MRT tool""" - unique_values = data_frame[variable].unique() # get the coordinates in the axis - upper = [x for x in unique_values if x > value][0] # find the closest values to the one selected - lower = [x for x in unique_values if x < value][-1] - closest_distance = data_frame.loc[data_frame[variable] == upper, axis].values[0] - further_distance = data_frame.loc[data_frame[variable] == lower, axis].values[0] - array_distances = np.linspace(closest_distance, further_distance, 100) - result = [] - for distance in array_distances: - result.append([distance, (distance - closest_distance) / (further_distance - closest_distance) * (lower - upper) + upper]) - - _ = pd.DataFrame(result, columns=[axis, variable]) - return _.loc[_[variable] <= 0.5, axis].min() # return results of interpolation - - -plt.close('all') - -# directory containing input files -dir_files = os.path.join(os.getcwd(), 'ASHRAE 55 Tables', 'Output MRT tool') -variable_of_interest = 'PMV' -axis_along_which_window_is_installed = 'x' -center_of_the_wall = 7.5 # value in meters - -# check how many calculaitons where performed, for each set of input 4 files are outputted by the code -runs = [] -for file in glob.glob(os.path.join(dir_files, "*.txt")): - runs.append(file.split('_', 2)[2].split('.txt')[0]) -runs = set(runs) - -# store all the results in one single Pandas data frame -df_runs = pd.DataFrame() -for run in runs: - df_run = pd.DataFrame() - for ix, file in enumerate(glob.glob(os.path.join(dir_files, f"*{run}.txt"))): - df = pd.read_csv(os.path.join(dir_files, file), sep=',', header=None).transpose() - if ix == 0: - df_run[file.split('_')[1]] = df.values[:, 0] - else: - df_run[file.split('_')[1]] = df.values - - df_run['Run'] = file.split('_', 2)[2].split('.txt')[0] - df_runs = df_runs.append(df_run) - -# plt the results and calculate the minimum distance from the window. this value is calculated in the center of the room -cm = plt.cm.get_cmap('RdYlBu_r') -results = dict() -for run in runs: - df_results = pd.DataFrame() - df_run = df_runs[df_runs.Run == run] - - df_results[variable_of_interest] = interpolation(df_run, value=center_of_the_wall, axis=axis_along_which_window_is_installed, variable=variable_of_interest) - df_results['distance'] = df_run.z.unique() - df_results['x'] = center_of_the_wall - - plt.figure() - sc = plt.scatter(x=df_run.x, y=df_run.z, c=df_run.PMV, cmap=cm, vmin=0.501, vmax=0.7, marker='s', s=150) - plt.scatter(x=df_results['x'], y=df_results['distance'], c=df_results[variable_of_interest], cmap=cm, vmin=0.5, vmax=0.7, marker='s', s=150) - plt.ylim(0, 5) - plt.colorbar(sc, extend='both') - plt.title(run) - plt.savefig(os.path.join(os.getcwd(), 'ASHRAE 55 Tables', 'Figures', f'{run}.png'), dpi=300) - plt.close('all') - - # calculate the min distance from the wall - min_distance = find_min_distance(df_results, value=0.5, axis='distance', variable='PMV') - results[run] = round(min_distance, 2) - -pprint(results) - -# save results in a cvs -df_min_distances = pd.DataFrame([results]).T.reset_index() -df_min_distances['fbes'] = df_min_distances['index'].str.split('_', expand=True)[1] -df_min_distances['posture'] = df_min_distances['index'].str.split('_', expand=True)[3] -df_min_distances['winTemp'] = df_min_distances['index'].str.split('_', expand=True)[5] -df_min_distances['tsol'] = df_min_distances['index'].str.split('_', expand=True)[7] -df_min_distances.drop(columns=['index'], inplace=True) -df_min_distances.rename(columns={0: 'Min Distance [m]'}, inplace=True) -df_min_distances.to_csv('results_min_distances.csv', index=False) diff --git a/js/main.js b/js/main.js index 7e66f5d..fe937e3 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,3 @@ -var output_data_for_ASHRAE_table = false; // by setting this variable to true the code automatically downloads the results of the calculation to a csv file so can be used later on to generate the tables for the ASHRAE 55 standard var container; var camera, scene, renderer, raycaster, projector, INTERSECTED, directionalLight; var surfaces = []; @@ -1321,11 +1320,6 @@ function render() { function update_view_factors(){ - // arrays that will be used to store the coordinates output_data_for_ASHRAE_table is set to true - let x_location = []; - let y_location = []; - let z_location = []; - view_factors = _.map(plane.geometry.vertices, function(v){ var my_vector = new THREE.Vector3(); my_vector.copy(v); @@ -1341,32 +1335,9 @@ function update_view_factors(){ for (var i = 0; i < vfs.length; i++){ vfs[i].view_factor *= norm_factor; } - if (output_data_for_ASHRAE_table) { - x_location.push(my_vector.x); - y_location.push(my_vector.y); - z_location.push(my_vector.z); - } return vfs; }); - if (output_data_for_ASHRAE_table) { - var link = document.createElement('a'); - link.setAttribute('href', 'data:text/plain,' + x_location.join(', ')); - let fileName = 'location_x_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; - link.setAttribute('download', fileName); - link.click(); - var link = document.createElement('a'); - link.setAttribute('href', 'data:text/plain,' + y_location.join(', ')); - fileName = 'location_y_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; - link.setAttribute('download', fileName); - link.click(); - var link = document.createElement('a'); - link.setAttribute('href', 'data:text/plain,' + z_location.join(', ')); - fileName = 'location_z_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; - link.setAttribute('download', fileName); - link.click(); - } - view_factors_need_updating = false; } @@ -1547,12 +1518,5 @@ function update_visualization(){ } } - if (output_data_for_ASHRAE_table) { - var link = document.createElement('a'); - link.setAttribute('href', 'data:text/plain,' + vertex_values.join(', ')); - const fileName = 'value_' + params.display + '_fbes_' + solarcal.fbes + '_posture_' + mrt.occupant.posture + '_winTemp_' + params.wall1.panel.temperature + '_tsol_' + params.wall1.panel.tsol + '.txt'; - link.setAttribute('download', fileName); - link.click(); - } plane.geometry.colorsNeedUpdate = true; }