-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
4,218 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cb005b8e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Thermo-mechanical NTFA: Examples from paper\n", | ||
"\n", | ||
"(c) 2024,\n", | ||
"Felix Fritzen <fritzen@simtech.uni-stuttgart.de>,\n", | ||
"Julius Herb <julius.herb@mib.uni-stuttgart.de>,\n", | ||
"Shadi Sharba <shadi.sharba@isc.fraunhofer.de>\n", | ||
"\n", | ||
"University of Stuttgart, Institute of Applied Mechanics, Chair for Data Analytics in Engineering\n", | ||
"\n", | ||
"> <table border=\"0\"><tr><td>\n", | ||
"> <h4>Funding acknowledgment</h4>\n", | ||
"> The IGF-Project no.: 21.079 N / DVS-No.: 06.3341 of the\n", | ||
"> “Forschungsvereinigung Schweißen und verwandte Verfahren e.V.” of the\n", | ||
"> German Welding Society (DVS), Aachener Str. 172, 40223 Düsseldorf, Germany,\n", | ||
"> was funded by the Federal Ministry for Economic Affairs and Climate Action (BMWK)\n", | ||
"> via the German Federation of Industrial Research Associations (AiF) in accordance\n", | ||
"> with the policy to support the Industrial Collective Research (IGF)\n", | ||
"> on the orders of the German Bundestag.\n", | ||
"> <br><br>\n", | ||
"> Felix Fritzen is funded by the German Research Foundation (DFG) --\n", | ||
"> 390740016 (EXC-2075); 406068690 (FR2702/8-1); 517847245 (FR2702/10-1).\n", | ||
"> </td><td><img src=\"../docs/images/bmwk.png\" width=\"40%\"></img></td></tr></table>\n", | ||
"\n", | ||
"## Imports" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "9da84841", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"import h5py\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "98e67329", | ||
"metadata": {}, | ||
"source": [ | ||
"## Twoscale loading plot:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "947ce749", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "FileNotFoundError", | ||
"evalue": "[Errno 2] Unable to synchronously open file (unable to open file: name = 'data/NTFA293K_fine_temp_293-800.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[2], line 6\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m s \u001b[38;5;129;01min\u001b[39;00m (\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfine\u001b[39m\u001b[38;5;124m\"\u001b[39m,): \u001b[38;5;66;03m# 'coarse', 'medium',\u001b[39;00m\n\u001b[1;32m 5\u001b[0m file_name \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNTFA293K_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00ms\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_temp_293-800.h5\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m----> 6\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[43mh5py\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mFile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mr\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m F:\n\u001b[1;32m 7\u001b[0m force\u001b[38;5;241m.\u001b[39mappend(np\u001b[38;5;241m.\u001b[39marray(F[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mforce28\u001b[39m\u001b[38;5;124m\"\u001b[39m]) \u001b[38;5;241m/\u001b[39m \u001b[38;5;241m1e6\u001b[39m)\n\u001b[1;32m 8\u001b[0m temp\u001b[38;5;241m.\u001b[39mappend(np\u001b[38;5;241m.\u001b[39marray(F[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtemperature28\u001b[39m\u001b[38;5;124m\"\u001b[39m]))\n", | ||
"File \u001b[0;32m~/Documents/ThermoNTFA/venv/lib/python3.11/site-packages/h5py/_hl/files.py:562\u001b[0m, in \u001b[0;36mFile.__init__\u001b[0;34m(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)\u001b[0m\n\u001b[1;32m 553\u001b[0m fapl \u001b[38;5;241m=\u001b[39m make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,\n\u001b[1;32m 554\u001b[0m locking, page_buf_size, min_meta_keep, min_raw_keep,\n\u001b[1;32m 555\u001b[0m alignment_threshold\u001b[38;5;241m=\u001b[39malignment_threshold,\n\u001b[1;32m 556\u001b[0m alignment_interval\u001b[38;5;241m=\u001b[39malignment_interval,\n\u001b[1;32m 557\u001b[0m meta_block_size\u001b[38;5;241m=\u001b[39mmeta_block_size,\n\u001b[1;32m 558\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwds)\n\u001b[1;32m 559\u001b[0m fcpl \u001b[38;5;241m=\u001b[39m make_fcpl(track_order\u001b[38;5;241m=\u001b[39mtrack_order, fs_strategy\u001b[38;5;241m=\u001b[39mfs_strategy,\n\u001b[1;32m 560\u001b[0m fs_persist\u001b[38;5;241m=\u001b[39mfs_persist, fs_threshold\u001b[38;5;241m=\u001b[39mfs_threshold,\n\u001b[1;32m 561\u001b[0m fs_page_size\u001b[38;5;241m=\u001b[39mfs_page_size)\n\u001b[0;32m--> 562\u001b[0m fid \u001b[38;5;241m=\u001b[39m \u001b[43mmake_fid\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muserblock_size\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfapl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfcpl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mswmr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mswmr\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 564\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(libver, \u001b[38;5;28mtuple\u001b[39m):\n\u001b[1;32m 565\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_libver \u001b[38;5;241m=\u001b[39m libver\n", | ||
"File \u001b[0;32m~/Documents/ThermoNTFA/venv/lib/python3.11/site-packages/h5py/_hl/files.py:235\u001b[0m, in \u001b[0;36mmake_fid\u001b[0;34m(name, mode, userblock_size, fapl, fcpl, swmr)\u001b[0m\n\u001b[1;32m 233\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m swmr \u001b[38;5;129;01mand\u001b[39;00m swmr_support:\n\u001b[1;32m 234\u001b[0m flags \u001b[38;5;241m|\u001b[39m\u001b[38;5;241m=\u001b[39m h5f\u001b[38;5;241m.\u001b[39mACC_SWMR_READ\n\u001b[0;32m--> 235\u001b[0m fid \u001b[38;5;241m=\u001b[39m \u001b[43mh5f\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mopen\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mflags\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfapl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfapl\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 236\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m mode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mr+\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[1;32m 237\u001b[0m fid \u001b[38;5;241m=\u001b[39m h5f\u001b[38;5;241m.\u001b[39mopen(name, h5f\u001b[38;5;241m.\u001b[39mACC_RDWR, fapl\u001b[38;5;241m=\u001b[39mfapl)\n", | ||
"File \u001b[0;32mh5py/_objects.pyx:54\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n", | ||
"File \u001b[0;32mh5py/_objects.pyx:55\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n", | ||
"File \u001b[0;32mh5py/h5f.pyx:102\u001b[0m, in \u001b[0;36mh5py.h5f.open\u001b[0;34m()\u001b[0m\n", | ||
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] Unable to synchronously open file (unable to open file: name = 'data/NTFA293K_fine_temp_293-800.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"dpi = 400\n", | ||
"force = []\n", | ||
"temp = []\n", | ||
"for s in (\"fine\",): # 'coarse', 'medium',\n", | ||
" file_name = os.path.join(\"data\", f\"NTFA293K_{s}_temp_293-800.h5\")\n", | ||
" with h5py.File(file_name, mode=\"r\") as F:\n", | ||
" force.append(np.array(F[\"force28\"]) / 1e6)\n", | ||
" temp.append(np.array(F[\"temperature28\"]))\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1, dpi=dpi)\n", | ||
"labels = False\n", | ||
"for f, T in zip((force), (temp)):\n", | ||
" t = np.linspace(0, 2, f.size)\n", | ||
" ax.plot(t, f, \"-s\", ms=4, label=\"tensile force\", color=\"blue\")\n", | ||
" if labels:\n", | ||
" ax.plot(1.0, f[np.where(t == 1.0)], \"o\", color=\"black\", ms=6)\n", | ||
" else:\n", | ||
" ax2 = ax.twinx()\n", | ||
" nhalf = int((t.size + 1) / 2)\n", | ||
" # ax.plot(1.0, f[np.where(t==1.0)], 'o', color='black', ms=6, label='start unloading', zorder=4)\n", | ||
" ax.fill_between(\n", | ||
" t[:nhalf], f[:nhalf], np.zeros(nhalf), color=\"blue\", alpha=0.2, zorder=2\n", | ||
" )\n", | ||
" ax.fill_between(\n", | ||
" t[(nhalf - 1) :],\n", | ||
" f[(nhalf - 1) :],\n", | ||
" np.zeros(f.size - nhalf + 1),\n", | ||
" color=\"red\",\n", | ||
" alpha=0.2,\n", | ||
" zorder=2,\n", | ||
" )\n", | ||
" ax2.plot(t, T, \"-s\", ms=4, color=\"red\", zorder=4, label=\"temperature\")\n", | ||
" ax.set_xlabel(\"time [s]\")\n", | ||
" ax.set_ylabel(\"force [kN]\")\n", | ||
" ax2.set_ylabel(\"temperature [K]\")\n", | ||
" ax.text(0.4, 2, \"tensile loading\", color=\"blue\", bbox=dict(facecolor=\"white\"))\n", | ||
" ax.text(1.1, 2, \"force unloading\", color=\"red\", bbox=dict(facecolor=\"white\"))\n", | ||
" ax.grid(zorder=1)\n", | ||
" ax.legend(loc=(0.65, 0.825))\n", | ||
" ax2.legend(loc=(0.65, 0.7))\n", | ||
" nhalf = int((t.size + 1) / 2)\n", | ||
" labels = True\n", | ||
"fig.savefig(os.path.join(\"results\", \"twoscale_loading.pdf\"))\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f3a74e27", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot 2:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9945bf38", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots(1, 1, dpi=dpi)\n", | ||
"ax.plot((1.0, 1.0), (-0.05, 1.05), \"--\", color=\"gray\", lw=2, zorder=4)\n", | ||
"ax.fill_between((0.0, 1.0), (0.0, 1.0), (0.0, 0.0), color=\"blue\", alpha=0.2, zorder=2)\n", | ||
"ax.fill_between((1.0, 2.0), (1.0, 0.0), (0.0, 0.0), color=\"red\", alpha=0.2, zorder=2)\n", | ||
"ax.plot((0.0, 1.0), (0.0, 1.0), color=\"blue\", lw=2, zorder=1)\n", | ||
"ax.plot((1.0, 2.0), (1.0, 0.0), \"--\", color=\"red\", lw=2, zorder=1)\n", | ||
"ax.text(0.4, 0.1, \"tensile loading\", color=\"blue\", bbox=dict(facecolor=\"white\"))\n", | ||
"ax.text(1.1, 0.1, \"force unloading\", color=\"red\", bbox=dict(facecolor=\"white\"))\n", | ||
"ax.set_xlabel(\"time [s]\")\n", | ||
"ax.set_ylabel(r\"rel. stretch $u/u_\\mathrm{max}$ and force $F/F_\\mathrm{max}$ [-]\")\n", | ||
"ax.grid(zorder=3)\n", | ||
"fig.savefig(os.path.join(\"results\", \"twoscale_loading.pdf\"))\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a20c608b", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4354f0ab", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file_name = os.path.join(\"data\", \"test_coarse.h5\")\n", | ||
"with h5py.File(file_name, mode=\"r\") as F:\n", | ||
" u = np.array(F[\"displacement1/X\"])\n", | ||
" uy = u[1::2]\n", | ||
" D = np.array(F[\"DATA16/cData\"]).reshape((-1, 12))\n", | ||
" eps = D[:, :6]\n", | ||
" sig = D[:, :6]\n", | ||
" f = np.array(F[\"force16\"])[:17]\n", | ||
" print(\"uymax=\", uy.max())\n", | ||
" print(\"s_yy mean=\", sig[:, 2].mean())\n", | ||
"\n", | ||
"fig, ax = plt.subplots(1, 1, dpi=dpi)\n", | ||
"ax.plot(f)\n", | ||
"fig.savefig(os.path.join(\"results\", \"force.pdf\"))\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f9008e46", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "91d8f0b6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file_name = os.path.join(\"data\", \"test_coarse.h5\")\n", | ||
"with h5py.File(file_name, mode=\"r\") as F:\n", | ||
" d = []\n", | ||
" for i in range(16):\n", | ||
" D = np.array(F[f\"DATA{i+1}/cData\"])[:, 6:]\n", | ||
" d.append(D.mean(axis=0))\n", | ||
" d = np.array(d)\n", | ||
" plt.plot(d[:, 2])\n", | ||
"\n", | ||
" # f = np.array(F[\"force32\"])\n", | ||
" # print(f)\n", | ||
" # plt.plot(f)\n", | ||
" plt.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"jupytext": { | ||
"cell_metadata_filter": "-all", | ||
"encoding": "# -*- coding: utf-8 -*-", | ||
"executable": "/usr/bin/env python3", | ||
"formats": "ipynb,py:percent", | ||
"main_language": "python", | ||
"notebook_metadata_filter": "-all" | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.