{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MDOF Factory\n", "\n", "这个文件的主要功能就是测试各个 python 脚本,用来批量生成 MDOF 数据。包含几个步骤:\n", "\n", "1. 生成所需要的 BlgAttributes.txt 文件并复制到每个文件夹的 inputs 里面;\n", "2. 清空每个文件夹内的 Results 文件夹(或者以某种形式存起来,怕数据处理的时候出什么岔子);\n", "3. 运行批量运行 exe 文件的脚本 `Run_MDOF_Exe.py` ,等待 14 个 MDOF 文件夹内的 exe 脚本运行完毕;\n", "4. 读取买个文件夹的 Results 数据,将顶层结构加速度响应以及损伤等级保存到一个 hdf5 文件中;\n", "5. 重复以上四个步骤,直到所需要的情况训练完成。\n", " \n", "SeT-4.0 版本所需要的建筑类型一共有 30 种情况,包含 1~10 层框架结构在 6,7,8 度抗震设防下的情况。使用的地震动是 knet 的 3474 条地震动(@Jie Zheng 整理的),使用 57 个调幅系数(@Jie Zheng 整理的)。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 生成 case.txt 文件" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "case.txt has been created with 30 cases.\n" ] } ], "source": [ "# # 文件名\n", "# filename = 'case.txt'\n", "\n", "# # 打开文件以写入数据\n", "# with open(filename, 'w') as file:\n", "# # 写入标题行,包含number作为序号\n", "# file.write(\"number, Stories, height, IM, Site_CD\\n\")\n", "\n", "# # 初始化序号\n", "# number = 1\n", "\n", "# # 生成案例\n", "# for stories in range(1, 11): # 1到10层,包含10层\n", "# height = stories * 3 # 高度等于层数乘以3\n", "# site_cd = 2 # 场地类别为2\n", "# for im in range(6, 9): # 抗震设防烈度为6,7,8\n", "# # 写入案例数据,包括前面的序号\n", "# file.write(f\"{number}, {stories}, {height}, {im}, {site_cd}\\n\")\n", "# # 序号递增\n", "# number += 1\n", "\n", "# # 打印文件创建完成的消息\n", "# print(f\"{filename} has been created with {number - 1} cases.\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 生成所需要的 blgAttributes.txt 文件\n", "\n", "根据 case.txt 里面每一行的数据去更新 blgAttributes.txt" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from Update_BlgAttributes_txt import update_blgattributes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'Stories': '1', 'height': '3', 'IM': '7', 'Site_CD': '2'}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = update_blgattributes(case_No=2)\n", "results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 复制 blgAttributes.txt 文件到每个文件夹的 inputs 里面" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from Update_BlgAttributes_txt import update_blgattributes_txt" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "All BlgAttributes.txt files have been updated.\n" ] } ], "source": [ "update_blgattributes_txt()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 清空之前的 Results 文件" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "from Delete_Results_Folder import delete_results_folder" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "deleting results folder...\n" ] } ], "source": [ "delete_results_folder()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 批量运行 exe 计算" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from Run_MDOF_Exe import run_exes" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Running EXEs: 100%|██████████| 14/14 [00:00<00:00, 70.19exe/s]\n", "Waiting for EXEs to finish: 0%| | 0/14 [00:00