Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| background_css = """ | |
| <style> | |
| body { | |
| background-image: url("https://t4.ftcdn.net/jpg/08/51/51/19/360_F_851511987_yt28bGDYsX0iBoB7mSbyfMg4IABaCeQx.jpg"); | |
| background-size: cover; | |
| background-repeat: no-repeat; | |
| background-attachment: fixed; | |
| } | |
| </style> | |
| """ | |
| # Define categories with detailed options, ranges, weights, and scoring criteria | |
| categories = { | |
| "Window-to-Wall Ratio (WWR %)": {"range": (10, 80), "weight": 2, "criteria": [(20, 30), (10, 40), (0, 100)], "suggestion": "Consider reducing WWR to 20-30% for optimal cooling."}, | |
| "Building Orientation (Degrees)": {"range": (0, 180), "weight": 2, "criteria": [(0, 45),(315, 360),(90,270)], "suggestion": "Align building orientation between 0-45° for better sun control."}, | |
| "Shading Devices (Coverage %)": {"range": (0, 100), "weight": 2, "criteria": [(70, 100), (50, 69), (0, 49)], "suggestion": "Increase shading device coverage to 70-100% for effective sun protection."}, | |
| "Roof Reflectivity (Color/Material)": { | |
| "options": {"Cool White": 5, "Light Grey": 3, "Dark Grey": 1}, | |
| "weight": 1.6, | |
| "suggestion": "Opt for cool white roofing materials for maximum heat reflectivity." | |
| }, | |
| "Wall Reflectivity (Color/Material)": { | |
| "options": {"Light Colors (White/Beige)": 5, "Medium Colors (Grey)": 3, "Dark Colors (Black/Brown)": 1}, | |
| "weight": 1.6, | |
| "suggestion": "Use light-colored wall materials to improve thermal reflectivity." | |
| }, | |
| "Tree Coverage (%)": {"range": (0, 100), "weight": 2, "criteria": [(50, 100), (30, 49), (0, 29)], "suggestion": "Increase tree coverage to 50% or more for enhanced shading and cooling."}, | |
| "Pavement Material": { | |
| "options": {"Cool Pavement (Reflective)": 5, "Standard Concrete": 3, "Asphalt": 1}, | |
| "weight": 1, | |
| "suggestion": "Consider using reflective cool pavements to reduce heat absorption." | |
| }, | |
| "Cross Ventilation Efficiency (%)": {"range": (0, 100), "weight": 2, "criteria": [(70, 100), (50, 69), (0, 49)], "suggestion": "Ensure at least 70% efficiency in cross ventilation for optimal airflow."}, | |
| "Stack Ventilation Efficiency (%)": {"range": (0, 100), "weight": 1, "criteria": [(50, 100), (30, 49), (0, 29)], "suggestion": "Improve stack ventilation efficiency to above 50% for enhanced cooling."}, | |
| "Outdoor Shaded Spaces (%)": {"range": (0, 100), "weight": 1, "criteria": [(50, 100), (30, 49), (0, 29)], "suggestion": "Increase outdoor shaded spaces to at least 50% for better outdoor comfort."}, | |
| "Ventilated or Perforated Facades (%)": {"range": (0, 100), "weight": 1, "criteria": [(70, 100), (50, 69), (0, 49)], "suggestion": "Add more ventilated or perforated facades to reach 70% or higher."}, | |
| "Green Roof or Wall Coverage (%)": {"range": (0, 100), "weight": 1, "criteria": [(50, 100), (30, 49), (0, 29)], "suggestion": "Consider adding green roof or wall coverage of 50% or more for natural cooling."}, | |
| "Ceiling Fans and Ventilation (%)": {"range": (0, 100), "weight": 1, "criteria": [(70, 100), (50, 69), (0, 49)], "suggestion": "Increase ceiling fan coverage to at least 70% for effective indoor cooling."}, | |
| } | |
| def determine_score(value, criteria): | |
| """Determine score based on value and criteria ranges or options.""" | |
| if isinstance(criteria, list): # Range-based scoring | |
| if criteria[0][0] <= value <= criteria[0][1]: | |
| return 5 # Excellent | |
| elif criteria[1][0] <= value <= criteria[1][1]: | |
| return 3 # Good | |
| else: | |
| return 1 # Poor | |
| elif isinstance(criteria, dict): # Option-based scoring | |
| return criteria.get(value, 1) # Default to 1 (Poor) if value not in options | |
| # Title and description | |
| st.title("Building Design Scoring System for Hot and Humid Climates with Improvement Suggestions") | |
| st.sidebar.title("Inputs") | |
| # Initialize total score and suggestions | |
| total_score = 0 | |
| suggestions = [] | |
| # Collect scores based on real input values and dropdowns | |
| for category, details in categories.items(): | |
| if "range" in details: # Slider input | |
| min_val, max_val = details["range"] | |
| value = st.sidebar.slider(f"{category} (Range: {min_val}-{max_val})", min_value=float(min_val), max_value=float(max_val), value=(min_val+max_val)/2) | |
| score = determine_score(value, details["criteria"]) | |
| elif "options" in details: # Dropdown input | |
| options = list(details["options"].keys()) | |
| selected_option = st.sidebar.selectbox(f"{category} - Select Option", options) | |
| score = determine_score(selected_option, details["options"]) | |
| # Append suggestion if score is below 5 | |
| if score < 5 and "suggestion" in details: | |
| suggestions.append((category, details["suggestion"])) | |
| # Calculate weighted score | |
| weighted_score = score * details["weight"] | |
| total_score += weighted_score | |
| # Display the final score and rating | |
| st.subheader("Total Score") | |
| st.write(f"**{total_score:.2f} / 100**") | |
| # Rating system | |
| if total_score >= 80: | |
| st.success("Rating: Excellent – Highly suitable for hot and humid climates.") | |
| elif total_score >= 60: | |
| st.info("Rating: Good – Effective, though with room for improvement.") | |
| elif total_score >= 40: | |
| st.warning("Rating: Fair – Provides some cooling but lacks in key areas.") | |
| else: | |
| st.error("Rating: Poor – Requires significant improvements for climate adaptability.") | |
| # Display suggestions for improvement | |
| st.subheader("Suggestions for Improvement") | |
| if suggestions: | |
| st.write("Consider the following modifications to improve your building design:") | |
| for category, suggestion in suggestions: | |
| st.write(f"- **{category}**: {suggestion}") | |
| else: | |
| st.write("Your design is optimized for the climate!") | |