def test_passive_solar_polygon(): """Test the passive_solar_polygon method.""" # test the polygon with the default comfort settings path = './tests/epw/chicago.epw' epw = EPW(path) psych_chart = PsychrometricChart(epw.dry_bulb_temperature, epw.relative_humidity) poly_obj = PolygonPMV(psych_chart) sol_vals, delta = poly_obj.evaluate_passive_solar( epw.global_horizontal_radiation) sol_poly = poly_obj.passive_solar_polygon(delta) sol_poly = poly_obj.passive_solar_polygon(delta) assert len(sol_poly) == 4 assert 0 < sum(sol_vals) < 8760 # test the polygon with custom comfort settings psych_chart = PsychrometricChart(15, 30, max_temperature=40) pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) sol_vals, delta = poly_obj.evaluate_passive_solar([200]) sol_poly = poly_obj.passive_solar_polygon(delta) assert sol_vals == [1] # test the polygon with custom comfort settings psych_chart = PsychrometricChart(10, 30, max_temperature=40) pmv_par = PMVParameter(humid_ratio_upper=0.014, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) bal = 12.8 sol_vals, delta = poly_obj.evaluate_passive_solar([200], balance_temperature=bal) sol_poly = poly_obj.passive_solar_polygon(delta, bal) assert sol_vals == [1]
def test_fan_use_polygon(): """Test the fan_use_polygon method.""" # test the polygon with the default comfort settings psych_chart = PsychrometricChart(20, 50) poly_obj = PolygonPMV(psych_chart) fan_poly = poly_obj.fan_use_polygon() val_list = poly_obj.evaluate_polygon(fan_poly) assert val_list == [0] # test the polygon with custom comfort settings psych_chart = PsychrometricChart(30, 30) pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) fan_poly = poly_obj.fan_use_polygon(1.5) val_list = poly_obj.evaluate_polygon(fan_poly) assert val_list == [1]
def test_evaporative_cooling_polygon(): """Test the evaporative_cooling_polygon method.""" # test the polygon with the default comfort settings psych_chart = PsychrometricChart(20, 50) poly_obj = PolygonPMV(psych_chart) evap_poly = poly_obj.evaporative_cooling_polygon() val_list = poly_obj.evaluate_polygon(evap_poly) assert val_list == [0] # test the polygon with custom comfort settings psych_chart = PsychrometricChart(35, 10) pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) evap_poly = poly_obj.evaporative_cooling_polygon() val_list = poly_obj.evaluate_polygon(evap_poly) assert val_list == [1]
def test_internal_heat_polygon(): """Test the internal_heat_polygon method.""" # test the polygon with the default comfort settings psych_chart = PsychrometricChart(25, 50) poly_obj = PolygonPMV(psych_chart) inht_poly = poly_obj.internal_heat_polygon() val_list = poly_obj.evaluate_polygon(inht_poly) assert val_list == [0] # test the polygon with custom comfort settings psych_chart = PsychrometricChart(15, 50) pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) inht_poly = poly_obj.internal_heat_polygon() val_list = poly_obj.evaluate_polygon(inht_poly) assert val_list == [1]
def test_data_mesh(): """Test the data_mesh meshod.""" path = './tests/fixtures/epw/tokyo.epw' epw = EPW(path) psych_chart = PsychrometricChart(epw.dry_bulb_temperature, epw.relative_humidity) test_pt = psych_chart.plot_point(20, 50) assert isinstance(test_pt, Point2D) mesh = psych_chart.colored_mesh assert isinstance(mesh, Mesh2D) assert len(mesh.faces) > 1 data_mesh, container = psych_chart.data_mesh(epw.wind_speed) assert isinstance(data_mesh, Mesh2D) assert len(mesh.faces) == len(data_mesh.faces) > 1 assert isinstance(container, GraphicContainer)
def test_psychchart_to_from_dict(): """Test the initialization of PsychrometricChart and basic properties.""" psych_chart = PsychrometricChart(20, 50, 101000, None, Point2D(100, 100), 1.5, 1000, 0, 110, 0.025, True) chart_dict = psych_chart.to_dict() new_chart = PsychrometricChart.from_dict(chart_dict) assert new_chart.to_dict() == chart_dict assert new_chart.temperature == 20 assert new_chart.relative_humidity == 50 assert new_chart.average_pressure == 101000 assert new_chart.base_point == Point2D(100, 100) assert new_chart.x_dim == 1.5 assert new_chart.y_dim == 1000 assert new_chart.min_temperature == 0 assert new_chart.max_temperature == 110 assert new_chart.max_humidity_ratio == 0.025 assert new_chart.use_ip
def test_psychchart_from_epw(): """Test the initialization of PsychrometricChart from an EPW file.""" path = './tests/fixtures/epw/tokyo.epw' psych_chart = PsychrometricChart.from_epw(path, base_point=Point2D(100, 100), min_temperature=-10, max_temperature=40) mesh = psych_chart.colored_mesh assert isinstance(mesh, Mesh2D) assert len(mesh.faces) > 1
def test_night_flush_polygon(): """Test the night_flush_polygon method.""" # test the polygon with the default comfort settings path = './tests/epw/chicago.epw' epw = EPW(path) psych_chart = PsychrometricChart(epw.dry_bulb_temperature, epw.relative_humidity) poly_obj = PolygonPMV(psych_chart) nf_poly = poly_obj.night_flush_polygon() val_list = poly_obj.evaluate_night_flush_polygon(nf_poly, epw.dry_bulb_temperature) assert 0 < sum(val_list) < 8760 # test the polygon with custom comfort settings psych_chart = PsychrometricChart(30, 30, max_temperature=40) pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005) poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par) nf_poly = poly_obj.night_flush_polygon(16) val_list = poly_obj.evaluate_night_flush_polygon(nf_poly, [20]) assert val_list == [1]
def test_polygonpmv_init(): """Test the initialization of PolygonPMV and basic properties.""" path = './tests/epw/chicago.epw' psych_chart = PsychrometricChart.from_epw(path) poly_obj = PolygonPMV(psych_chart, clo_value=[0.5, 1.0]) str(poly_obj) # test the sting representation assert poly_obj.psychrometric_chart is psych_chart assert poly_obj.rad_temperature == (None, None) assert poly_obj.air_speed == (0.1, 0.1) assert poly_obj.met_rate == (1.1, 1.1) assert poly_obj.clo_value == (0.5, 1.0) assert poly_obj.external_work == (0, 0) assert poly_obj.comfort_parameter.ppd_comfort_thresh == 10 assert poly_obj.comfort_parameter.humid_ratio_upper == 1 assert poly_obj.comfort_parameter.humid_ratio_lower == 0 assert poly_obj.polygon_count == 2 assert len(poly_obj.left_comfort_lines) == 2 assert all( isinstance(pline, Polyline2D) for pline in poly_obj.left_comfort_lines) assert len(poly_obj.right_comfort_lines) == 2 assert all( isinstance(pline, Polyline2D) for pline in poly_obj.right_comfort_lines) assert isinstance(poly_obj.left_comfort_line, Polyline2D) assert isinstance(poly_obj.right_comfort_line, Polyline2D) assert len(poly_obj.comfort_polygons) == 2 assert len(poly_obj.merged_comfort_polygon) == 4 assert isinstance(poly_obj.merged_comfort_polygon[0], Polyline2D) assert isinstance(poly_obj.merged_comfort_polygon[1], LineSegment2D) assert isinstance(poly_obj.merged_comfort_polygon[2], Polyline2D) assert isinstance(poly_obj.merged_comfort_polygon[3], Polyline2D) assert len(poly_obj.comfort_values) == 2 assert all( isinstance(dat, HourlyContinuousCollection) for dat in poly_obj.comfort_data) assert len(poly_obj.merged_comfort_values) == 8760 assert isinstance(poly_obj.merged_comfort_data, HourlyContinuousCollection) assert not poly_obj.is_comfort_too_hot assert not poly_obj.is_comfort_too_cold
original_temperature = temperature all_data = data_ + [temperature, rel_humid] if period_ is not None: all_data = [ coll.filter_by_analysis_period(period_) for coll in all_data ] if statement_ is not None: all_data = BaseCollection.filter_collections_by_statement( all_data, statement_) # create the psychrometric chart object and draw it in the Rhino scene psy_chart = PsychrometricChart(all_data[-2], all_data[-1], pressure, leg_par_by_index(0), base_pt, x_dim, y_dim, t_min, t_max, use_ip=use_ip) psy_chart.z = z psy_chart.original_temperature = original_temperature draw_psych_chart(psy_chart) if isinstance(all_data[-2], BaseCollection): meta_i = all_data[-2].header.metadata.items() title_items = ['Time [hr]' ] + ['{}: {}'.format(k, v) for k, v in meta_i] else: title_items = ['Psychrometric Chart'] title[j + j * len(data_)].append( text_objects('\n'.join(title_items),
def test_psychchart_init(): """Test the initialization of PsychrometricChart and basic properties.""" psych_chart = PsychrometricChart(20, 50) str(psych_chart) # test the string representation assert psych_chart.temperature == 20 assert psych_chart.relative_humidity == 50 assert psych_chart.average_pressure == 101325 assert isinstance(psych_chart.legend_parameters, LegendParameters) assert psych_chart.base_point == Point2D(0, 0) assert psych_chart.x_dim == 1 assert psych_chart.y_dim == 1500 assert psych_chart.min_temperature == -20 assert psych_chart.max_temperature == 50 assert psych_chart.max_humidity_ratio == 0.03 assert not psych_chart.use_ip mesh = psych_chart.colored_mesh assert isinstance(mesh, Mesh2D) assert len(mesh.faces) == 1 data_points = psych_chart.data_points assert all(isinstance(pt, Point2D) for pt in data_points) hour_values = psych_chart.hour_values assert all(isinstance(pt, (float, int)) for pt in hour_values) time_matrix = psych_chart.time_matrix assert all(isinstance(pt, tuple) for pt in time_matrix) sat_line = psych_chart.saturation_line assert isinstance(sat_line, Polyline2D) border = psych_chart.chart_border assert isinstance(border, Polyline2D) assert len(border.segments) == 4 temp_txt = psych_chart.temperature_labels assert all(isinstance(txt, str) for txt in temp_txt) temp_lines = psych_chart.temperature_lines temp_pts = psych_chart.temperature_label_points assert len(temp_lines) == len(temp_txt) == len(temp_pts) assert all(isinstance(line, LineSegment2D) for line in temp_lines) assert all(isinstance(pt, Point2D) for pt in temp_pts) rh_txt = psych_chart.rh_labels assert all(isinstance(txt, str) for txt in rh_txt) rh_lines = psych_chart.rh_lines rh_pts = psych_chart.rh_label_points assert len(rh_txt) == len(rh_pts) assert len(rh_lines) == 10 assert all(isinstance(line, Polyline2D) for line in rh_lines) assert all(isinstance(pt, Point2D) for pt in rh_pts) hr_txt = psych_chart.hr_labels assert all(isinstance(txt, str) for txt in hr_txt) hr_lines = psych_chart.hr_lines hr_pts = psych_chart.hr_label_points assert len(hr_lines) == len(hr_txt) == len(hr_pts) assert all(isinstance(line, LineSegment2D) for line in hr_lines) assert all(isinstance(pt, Point2D) for pt in hr_pts) enthalpy_txt = psych_chart.enthalpy_labels assert all(isinstance(txt, str) for txt in enthalpy_txt) enthalpy_lines = psych_chart.enthalpy_lines enthalpy_pts = psych_chart.enthalpy_label_points assert len(enthalpy_lines) == len(enthalpy_txt) == len(enthalpy_pts) assert all(isinstance(line, LineSegment2D) for line in enthalpy_lines) assert all(isinstance(pt, Point2D) for pt in enthalpy_pts) wb_txt = psych_chart.wb_labels assert all(isinstance(txt, str) for txt in wb_txt) wb_lines = psych_chart.wb_lines wb_pts = psych_chart.wb_label_points assert len(wb_lines) == len(wb_txt) == len(wb_pts) assert all(isinstance(line, LineSegment2D) for line in wb_lines) assert all(isinstance(pt, Point2D) for pt in wb_pts) assert isinstance(psych_chart.legend, Legend) assert isinstance(psych_chart.container, GraphicContainer) assert isinstance(psych_chart.title_text, str) assert isinstance(psych_chart.y_axis_text, str) assert isinstance(psych_chart.x_axis_text, str) assert isinstance(psych_chart.title_location, Point2D) assert isinstance(psych_chart.x_axis_location, Point2D) assert isinstance(psych_chart.y_axis_location, Point2D)