{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "executionInfo": { "elapsed": 4534, "status": "ok", "timestamp": 1745783879773, "user": { "displayName": "Gang Jiang", "userId": "14372238440999662262" }, "user_tz": 360 }, "id": "U6wJ62qjwPz8" }, "outputs": [], "source": [ "# ⚠️ Please make sure you have adequate GPU memory.\n", "# ⚠️ Please make sure your EnergyPlus version is 9.6 for successful running.\n", "\n", "! pip install -U bitsandbytes -q # pip this repo at the first time." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 631, "referenced_widgets": [ "e7585d867fa3458e9ebdc466b90ec50a", "c0dd32a5465a411980afc081a14c8a94", "12396fb59bfe4caba1afd4ebdd3c7166", "31523936a58248c1ad48734679a19e1b", "6bb7e87ec01540afa838fc3a32863086", "af96d619c88e4ae09bd08608f4044fb1", "ff7722b5607f427bafe1908968793aa3", "2d0e7dcbb89c42cba38c517b846ea87d", "1fc1604b618d45e6aac8cd96ff1538ad", "98e0e5d89251416aad4e0c0aeee6388f", "e5b6950cf9d844a69b92b45601992e48" ] }, "executionInfo": { "elapsed": 185162, "status": "error", "timestamp": 1745784064933, "user": { "displayName": "Gang Jiang", "userId": "14372238440999662262" }, "user_tz": 360 }, "id": "wKnRwGpxujPF", "outputId": "3929f469-ef41-41ee-c6e1-1581da43fd9e" }, "outputs": [], "source": [ "from transformers import AutoModelForSeq2SeqLM, AutoTokenizer\n", "import torch\n", "from peft import PeftModel, PeftConfig\n", "import os\n", "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n", "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", "\n", "# Load the EPlus-LLMv2 config.\n", "peft_model_id = \"EPlus-LLM/EPlus-LLMv2\"\n", "config = PeftConfig.from_pretrained(peft_model_id)\n", "\n", "# Load the base LLM, flan-t5-xxl, and tokenizer\n", "model = AutoModelForSeq2SeqLM.from_pretrained(\"google/flan-t5-xxl\", load_in_8bit=True)\n", "tokenizer = AutoTokenizer.from_pretrained(\"google/flan-t5-xxl\")\n", "\n", "# Load the Lora model\n", "model = PeftModel.from_pretrained(model, peft_model_id)\n", "\n", "# Generation config\n", "generation_config = model.generation_config\n", "generation_config.max_new_tokens = 5000\n", "generation_config.temperature = 0.1\n", "generation_config.top_p = 0.1\n", "generation_config.num_return_sequences = 1\n", "generation_config.pad_token_id = tokenizer.eos_token_id\n", "generation_config.eos_token_id = tokenizer.eos_token_id\n", "\n", "# Please provide your input here — a description of the desired building\n", "# For more details, please refer to the paper: https://doi.org/10.1016/j.autcon.2025.106223\n", "input=f\"\"\"\n", "Simulate a U-shaped building that is 99.73 meters high, with a gable roof. \n", "The horizontal segment is 732.31 meters long and 17.54 meters wide. The left vertical segment is 256.31 meters long and 206.96 meters wide. The right vertical segment is 431.54 meters long and 62 meters wide. \n", "The roof ridge is 8.77 meters to the length side of the horizontal segment, and 128.16 meters, 215.77 meters to the width side of the vertical segments, respectively. \n", "The attic height is 139.71 meters. The building orientation is 62 degrees to the north. The building has 3 thermal zones with each segment as one thermal zone. \n", "The window-to-wall ratio is 0.32. The window sill height is 33.91 meters, the window height is 65.82 meters, and the window jamb width is 0.01 meters. \n", "The window U-factor is 6.36 W/m2K and the SHGC is 0.89. \n", "The wall is made of wood, with a thickness of 0.48 meters and the wall insulation is RSI 1.6 m2K/W, U-factor 0.63 W/m2K. \n", "The roof is made of metal, with a thickness of 0.09 meters and the roof insulation is RSI 5.4 m2K/W, U-factor 0.19 W/m2K. \n", "The floor is made of concrete, covered with carpet. The ventilation rate is 2.32 ach. The infiltration rate is 0.55 ach. \n", "The people density is 16.61 m2/person, the light density is 4.48 W/m2, and the electric equipment density is 22.63 W/m2. \n", "Occupancy starts at 7:00 and ends at 18:00. The occupancy rate is 1. The unoccupancy rate is 0.3. \n", "The heating setpoint is 21.54 Celsius in occupancy period and 15.86 Celsius in unoccupancy period. \n", "The cooling setpoint is 22.6 Celsius in occupancy period and 26.72 Celsius in unoccupancy period.\n", "\"\"\"\n", "\n", "# EPlus-LLM generating...\n", "input_ids = tokenizer(input, return_tensors=\"pt\", truncation=False).to(device)\n", "generated_ids = model.generate(input_ids = input_ids.input_ids,\n", " attention_mask = input_ids.attention_mask,\n", " generation_config = generation_config)\n", "generated_output = tokenizer.decode(generated_ids[0], skip_special_tokens=True)\n", "\n", "# Default thermal zones setting \n", "zone_1 = \"\"\"ZoneHVAC:EquipmentConnections,Thermal Zone 1,Thermal Zone 1 Equipment,Thermal Zone 1 Ideal Loads Supply Inlet,,Thermal Zone 1 Zone Air Node,Thermal Zone 1 Return Outlet;\n", "ZoneHVAC:EquipmentList,Thermal Zone 1 Equipment,SequentialLoad,ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 1 Ideal Loads Air System,1,1,,;\n", "ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 1 Ideal Loads Air System,,Thermal Zone 1 Ideal Loads Supply Inlet,,,50,13,0.0156,0.0077,NoLimit,,,NoLimit,,,,,ConstantSensibleHeatRatio,0.7,None,,,None,NoEconomizer,None,0.7,0.65;\n", "ZoneControl:Thermostat,Thermal Zone 1 Thermostat,Thermal Zone 1,Thermostat Schedule,ThermostatSetpoint:DualSetpoint,Thermostat Setpoint Dual Setpoint,,,,,,,0;\n", "Sizing:Zone,Thermal Zone 1,SupplyAirTemperature,14,11.11,SupplyAirTemperature,40,11.11,0.0085,0.008,Ventilation,,,DesignDay,0,0.000762,0,0,DesignDay,0,0.002032,0.1415762,0.3,,No;\"\"\"\n", "zone_2 = \"\"\"ZoneHVAC:EquipmentConnections,Thermal Zone 2,Thermal Zone 2 Equipment,Thermal Zone 2 Ideal Loads Supply Inlet,,Thermal Zone 2 Zone Air Node,Thermal Zone 2 Return Outlet;\n", "ZoneHVAC:EquipmentList,Thermal Zone 2 Equipment,SequentialLoad,ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 2 Ideal Loads Air System,1,1,,;\n", "ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 2 Ideal Loads Air System,,Thermal Zone 2 Ideal Loads Supply Inlet,,,50,13,0.0156,0.0077,NoLimit,,,NoLimit,,,,,ConstantSensibleHeatRatio,0.7,None,,,None,NoEconomizer,None,0.7,0.65;\n", "ZoneControl:Thermostat,Thermal Zone 2 Thermostat,Thermal Zone 2,Thermostat Schedule,ThermostatSetpoint:DualSetpoint,Thermostat Setpoint Dual Setpoint,,,,,,,0;\n", "Sizing:Zone,Thermal Zone 2,SupplyAirTemperature,14,11.11,SupplyAirTemperature,40,11.11,0.0085,0.008,Ventilation,,,DesignDay,0,0.000762,0,0,DesignDay,0,0.002032,0.1415762,0.3,,No;\"\"\"\n", "zone_3 = \"\"\"ZoneHVAC:EquipmentConnections,Thermal Zone 3,Thermal Zone 3 Equipment,Thermal Zone 3 Ideal Loads Supply Inlet,,Thermal Zone 3 Zone Air Node,Thermal Zone 3 Return Outlet;\n", "ZoneHVAC:EquipmentList,Thermal Zone 3 Equipment,SequentialLoad,ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 3 Ideal Loads Air System,1,1,,;\n", "ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 3 Ideal Loads Air System,,Thermal Zone 3 Ideal Loads Supply Inlet,,,50,13,0.0156,0.0077,NoLimit,,,NoLimit,,,,,ConstantSensibleHeatRatio,0.7,None,,,None,NoEconomizer,None,0.7,0.65;\n", "ZoneControl:Thermostat,Thermal Zone 3 Thermostat,Thermal Zone 3,Thermostat Schedule,ThermostatSetpoint:DualSetpoint,Thermostat Setpoint Dual Setpoint,,,,,,,0;\n", "Sizing:Zone,Thermal Zone 3,SupplyAirTemperature,14,11.11,SupplyAirTemperature,40,11.11,0.0085,0.008,Ventilation,,,DesignDay,0,0.000762,0,0,DesignDay,0,0.002032,0.1415762,0.3,,No;\"\"\"\n", "zone_4 = \"\"\"ZoneHVAC:EquipmentConnections,Thermal Zone 4,Thermal Zone 4 Equipment,Thermal Zone 4 Ideal Loads Supply Inlet,,Thermal Zone 4 Zone Air Node,Thermal Zone 4 Return Outlet;\n", "ZoneHVAC:EquipmentList,Thermal Zone 4 Equipment,SequentialLoad,ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 4 Ideal Loads Air System,1,1,,;\n", "ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 4 Ideal Loads Air System,,Thermal Zone 4 Ideal Loads Supply Inlet,,,50,13,0.0156,0.0077,NoLimit,,,NoLimit,,,,,ConstantSensibleHeatRatio,0.7,None,,,None,NoEconomizer,None,0.7,0.65;\n", "ZoneControl:Thermostat,Thermal Zone 4 Thermostat,Thermal Zone 4,Thermostat Schedule,ThermostatSetpoint:DualSetpoint,Thermostat Setpoint Dual Setpoint,,,,,,,0;\n", "Sizing:Zone,Thermal Zone 4,SupplyAirTemperature,14,11.11,SupplyAirTemperature,40,11.11,0.0085,0.008,Ventilation,,,DesignDay,0,0.000762,0,0,DesignDay,0,0.002032,0.1415762,0.3,,No;\"\"\"\n", "zone_5 = \"\"\"ZoneHVAC:EquipmentConnections,Thermal Zone 5,Thermal Zone 5 Equipment,Thermal Zone 5 Ideal Loads Supply Inlet,,Thermal Zone 5 Zone Air Node,Thermal Zone 5 Return Outlet;\n", "ZoneHVAC:EquipmentList,Thermal Zone 5 Equipment,SequentialLoad,ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 5 Ideal Loads Air System,1,1,,;\n", "ZoneHVAC:IdealLoadsAirSystem,Thermal Zone 5 Ideal Loads Air System,,Thermal Zone 5 Ideal Loads Supply Inlet,,,50,13,0.0156,0.0077,NoLimit,,,NoLimit,,,,,ConstantSensibleHeatRatio,0.7,None,,,None,NoEconomizer,None,0.7,0.65;\n", "ZoneControl:Thermostat,Thermal Zone 5 Thermostat,Thermal Zone 5,Thermostat Schedule,ThermostatSetpoint:DualSetpoint,Thermostat Setpoint Dual Setpoint,,,,,,,0;\n", "Sizing:Zone,Thermal Zone 5,SupplyAirTemperature,14,11.11,SupplyAirTemperature,40,11.11,0.0085,0.008,Ventilation,,,DesignDay,0,0.000762,0,0,DesignDay,0,0.002032,0.1415762,0.3,,No;\"\"\"\n", "generated_output = generated_output.replace(\"Ideal Load System Setting for Thermal Zone 1;\", zone_1)\n", "generated_output = generated_output.replace(\"Ideal Load System Setting for Thermal Zone 2;\", zone_2)\n", "generated_output = generated_output.replace(\"Ideal Load System Setting for Thermal Zone 3;\", zone_3)\n", "generated_output = generated_output.replace(\"Ideal Load System Setting for Thermal Zone 4;\", zone_4)\n", "generated_output = generated_output.replace(\"Ideal Load System Setting for Thermal Zone 5;\", zone_5)\n", "\n", "# Load the rest port of IDF file.\n", "file_path = \"v2_nextpart.idf\"\n", "output_path = \"v2_final.idf\"\n", "# Output the building energy model in IDF file\n", "with open(file_path, 'r', encoding='utf-8') as file:\n", " nextpart = file.read()\n", "final_text = nextpart + \"\\n\\n\" + generated_output\n", "with open(output_path, 'w', encoding='utf-8') as f:\n", " f.write(final_text)\n", "print(f\"Building Energy Model Auto-Generated: {output_path}\")" ] } ], "metadata": { "accelerator": "GPU", "colab": { "authorship_tag": "ABX9TyON1YYo2/wB54t5VKa5gcTl", "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "12396fb59bfe4caba1afd4ebdd3c7166": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "danger", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2d0e7dcbb89c42cba38c517b846ea87d", "max": 5, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_1fc1604b618d45e6aac8cd96ff1538ad", "value": 4 } }, "1fc1604b618d45e6aac8cd96ff1538ad": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "2d0e7dcbb89c42cba38c517b846ea87d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "31523936a58248c1ad48734679a19e1b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_98e0e5d89251416aad4e0c0aeee6388f", "placeholder": "​", "style": "IPY_MODEL_e5b6950cf9d844a69b92b45601992e48", "value": " 4/5 [02:45<00:41, 41.60s/it]" } }, "6bb7e87ec01540afa838fc3a32863086": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "98e0e5d89251416aad4e0c0aeee6388f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "af96d619c88e4ae09bd08608f4044fb1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "c0dd32a5465a411980afc081a14c8a94": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_af96d619c88e4ae09bd08608f4044fb1", "placeholder": "​", "style": "IPY_MODEL_ff7722b5607f427bafe1908968793aa3", "value": "Loading checkpoint shards:  80%" } }, "e5b6950cf9d844a69b92b45601992e48": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "e7585d867fa3458e9ebdc466b90ec50a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_c0dd32a5465a411980afc081a14c8a94", "IPY_MODEL_12396fb59bfe4caba1afd4ebdd3c7166", "IPY_MODEL_31523936a58248c1ad48734679a19e1b" ], "layout": "IPY_MODEL_6bb7e87ec01540afa838fc3a32863086" } }, "ff7722b5607f427bafe1908968793aa3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } } } } }, "nbformat": 4, "nbformat_minor": 0 }