建筑能耗分析工具

UBEM Analysis MCP Server 是一个用于EnergyPlus模拟的城市建筑能耗模型分析工具,提供天气分析、IDF修改、批量模拟和数据提取功能,适用于建筑能源管理和系统故障模拟场景。

  • by UBEM-MCP
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 JINGFENGZ/ubem-mcp

使用说明

UBEM分析MCP服务器

用于EnergyPlus模拟的城市建筑能源模型(UBEM)分析工具,打包为模型上下文协议(MCP)服务器。

🌟 特性

  • 天气分析:从EPW天气文件中识别最热的连续天数序列
  • IDF修改:自动修改停电情况下的暖通空调时间表
  • 批处理仿真:高效运行多栋建筑的EnergyPlus模拟
  • 数据提取:从任何输出变量中提取区域温度和能量指标
  • 场景比较:比较基线与修改后的暖通空调方案
  • 完全可配置:所有参数都公开,硬编码最少
  • MCP集成:LLM集成的标准MCP协议

🎯 设计理念

此MCP服务器旨在 最大限度的灵活性和最低限度的固执己见:

  • ✅ 没有硬编码路径:用户指定的所有目录和文件
  • ✅ 可配置变量:提取任何输出变量,而不仅仅是温度
  • ✅ 自动检测:可能时自动检测EnergyPlus安装
  • ✅ 可选参数:合理的默认设置,覆盖任何内容
  • ✅ 普遍适用性:适用于任何EnergyPlus项目结构

📋 安装

先决条件

  • Python 3.10或更高版本
  • EnergyPlus v25.1.0(或兼容版本)
  • pip(Python包管理器)

从源代码安装

git clone https://github.com/UBEM-MCP/ubem-mcp-opensource
cd ubem-mcp
pip install -e .

⚡ 快速开始

1.设置EnergyPlus路径(可选)

服务器会自动检测常见的EnergyPlus安装位置。如果需要,设置:

export ENERGYPLUS_ROOT="/path/to/EnergyPlus"

备注:不需要特定于项目的配置!所有路径都作为工具参数传递。

2.运行MCP服务器

python -m ubem_analysis_mcp.server

3.与MCP客户端一起使用

配置您的MCP客户端(例如,Claude Desktop):

{
  "mcpServers": {
    "ubem-analysis": {
      "command": "python",
      "args": ["-m", "ubem_analysis_mcp.server"],
      "env": {
        "ENERGYPLUS_ROOT": "/path/to/EnergyPlus"
      }
    }
  }
}

或者让它自动检测:

{
  "mcpServers": {
    "ubem-analysis": {
      "command": "python",
      "args": ["-m", "ubem_analysis_mcp.server"]
    }
  }
}

🛠️ 工具

1. analyze_weather_file

分析EPW天气文件以确定最热天气 连续N天序列 基于日平均温度。

2. modify_idf_hvac

修改单个IDF文件HVAC明细表以模拟停电情况。

3. batch_modify_idf_hvac

批量修改多个IDF文件以创建修改后的场景模型。

4. run_simulation

对单个建筑运行EnergyPlus模拟。

5. batch_simulate

对多个建筑物运行模拟。

6. analyze_results

分析模拟结果并计算统计数据。

7. generate_hourly_temperatures

根据模拟结果生成每小时温度CSV。

8. create_temperature_comparison

在基线和修改后的方案之间创建CSV比较。

📖 使用示例

完整的工作流程:极端高温和停电恢复能力评估

from ubem_analysis_mcp.tools.weather_analysis import analyze_epw_hottest_days
from ubem_analysis_mcp.tools.idf_modification import batch_modify_idf_hvac_schedule
from ubem_analysis_mcp.tools.simulation_tools import batch_simulate_buildings
from ubem_analysis_mcp.tools.data_analysis import create_comparison_csv

# Step 1: Find hottest consecutive 3-day sequence
weather_result = analyze_epw_hottest_days("weather/Shanghai.epw", top_n=3)
hottest_day = weather_result["earliest_hot_day"]  # First day of the sequence
start_month = hottest_day["month"]
start_day = hottest_day["day"]
print(f"HVAC outage will start from: {start_month:02d}/{start_day:02d} (Day 1 of heatwave)")

# Step 2: Create modified IDF files (simulate cooling outage)
modify_result = batch_modify_idf_hvac_schedule(
    idf_directory="baseline_models",
    output_directory="modified_models",
    idd_file="/path/to/Energy+.idd",
    schedule_action="disable_cooling",
    start_month=start_month,
    start_day=start_day
)
print(f"Modified {modify_result['successful_modifications']} IDF files")

# Step 3: Run baseline simulations
baseline_result = batch_simulate_buildings(
    idf_directory="baseline_models",
    weather_file="weather/Shanghai.epw",
    output_base_dir="results/baseline"
)

# Step 4: Run modified simulations
modified_result = batch_simulate_buildings(
    idf_directory="modified_models",
    weather_file="weather/Shanghai.epw",
    output_base_dir="results/modified"
)

# Step 5: Create comparison report
comparison_result = create_comparison_csv(
    baseline_results_dir="results/baseline",
    modified_results_dir="results/modified",
    output_csv="temperature_comparison.csv"
)
print(f"Mean temperature increase: {comparison_result['statistics']['mean_increase']:.2f}°C")

仅天气分析

from ubem_analysis_mcp.tools.weather_analysis import analyze_epw_hottest_days

result = analyze_epw_hottest_days("path/to/weather.epw", top_n=3)
if result["success"]:
    print(f"Hottest day: {result['earliest_hot_day']['date']}")

仅限IDF修改

from ubem_analysis_mcp.tools.idf_modification import modify_idf_hvac_schedule

# Disable cooling from July 15 onwards
result = modify_idf_hvac_schedule(
    idf_path="baseline_model.idf",
    output_path="modified_model.idf",
    idd_file="/path/to/Energy+.idd",
    schedule_action="disable_cooling",
    start_month=7,
    start_day=15
)

看 examples/ 目录以获取更多示例。

⚙️ 配置

默认配置使用环境变量:

  • UBEM_PROJECT_ROOT:您的项目根目录
  • ENERGYPLUS_ROOT:EnergyPlus安装目录

或编辑 ubem_analysis_mcp/config.py 直接。

🧪 发展

设置开发环境

git clone https://github.com/UBEM-MCP/ubem-mcp-opensource
cd ubem-mcp
pip install -e ".[dev]"

运行测试

pytest tests/

代码格式化

black ubem_analysis_mcp/
ruff check ubem_analysis_mcp/

🤝 贡献

欢迎投稿!请看 贡献.md 作为指导方针。

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢

📬 支持

  • 问题: https://github.com/UBEM-MCP/ubem-mcp-opensource/issues
  • 讨论: https://github.com/UBEM-MCP/ubem-mcp-opensource/discussions

📊 项目状态

该项目正在积极维护中。当前版本: 1.2.1


由...制作❤️ UBEM分析团队