{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "123a67e4",
   "metadata": {},
   "source": [
    "# Fatigue failure model"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c66fcc01",
   "metadata": {},
   "source": [
    "<a href=\"../handbook/reliability_prediction/structural_models_equations.html#modelling-of-failures-due-to-fatigue\" class=\"back-forward-button\">Go to handbook</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ff83f3e",
   "metadata": {},
   "source": [
    "## Model description\n",
    "\n",
    "Fatigue is a failure mechanism incurred by cyclic loading, leading to the initiation and extension of cracks, which degrade the strength of materials and structures. We consider here case of high-cycle fatigue failure, i.e., failures that occurs after a modelled component is exposed to large numbers of load cycles. The limit state function for this type of failure can be written as:\n",
    "\n",
    "$$\n",
    "g\\left( D_{cr}, A, \\text{SSF}, \\Theta  \\right) = D_{cr} - \\Theta \\cdot 10^{- A} {\\text{SSF}}^{B} \\sum_{j = 1}^{k}{N_{j} {S_{eq,j}}^{B}},\n",
    "$$\n",
    "\n",
    "This expression contains a set of variables that we consider uncertain ($D_{cr}, A, \\text{SSF}, \\Theta$) and parameters that we consider to be known with a sufficiently high accuracy ($B, \\{S_{eq,j}, N_j\\}_{j=1,\\cdots,N}$). A summary of these variables and their meaning is given in {numref}`fatigue_model_inputs_table`.\n",
    "\n",
    "```{list-table} Input variables for reliability analysis\n",
    ":header-rows: 1\n",
    ":widths: 15 45 20 20\n",
    ":name: fatigue_model_inputs_table\n",
    "\n",
    "* - Name\n",
    "  - Description\n",
    "  - Unit\n",
    "  - Type\n",
    "* - $D_{cr}$/D_cr\n",
    "  - Threshold for accumulated damage\n",
    "  - $-$\n",
    "  - uncertain\n",
    "* - $A$/A\n",
    "  - S/N curve slope\n",
    "  - $\\log(N/m^2)^{-1}$\n",
    "  - uncertain\n",
    "* - $B$/B\n",
    "  - S/N curve intercept\n",
    "  - $-$\n",
    "  - deterministic\n",
    "* - SSF\n",
    "  - Global stress scaling factor\n",
    "  - $-$\n",
    "  - uncertain\n",
    "* - $S$/S\n",
    "  - Load collective distribution\n",
    "  - $N/m^2$\n",
    "  - deterministic\n",
    "* - $N$/N\n",
    "  - Number of load cycles\n",
    "  - $-$\n",
    "  - deterministic\n",
    "* - $\\Theta$/Theta\n",
    "  - Model uncertainty\n",
    "  - $-$\n",
    "  - uncertain\n",
    "```\n",
    "\n",
    "### Load collective\n",
    "\n",
    "The load collective is the set of load events that the component was subjected to during its lifetime. The collective is denoted here by $\\{S_{eq,j}, N_j\\}_{j=1,\\cdots,N}$. To simplify usage of this interactive tool, the user can specify a distribution from which the load collective is sampled and a number of total load cycles $N$. The generated distribution is then shown in a plot after the analysis.\n",
    "\n",
    "## Interactive reliability prediction\n",
    "\n",
    "This page offers an interactive reliability prediction that lets the user specify the properties of all variables listed in {numref}`fatigue_model_inputs_table`. The value of **deterministic variables** can be selected with a slider. **Uncertain variables** are characterized by:\n",
    "- _Distribution_ denoted by \"Dist\" and can be choosen from a set of parametric probability distributions;\n",
    "- _Mean_ value denoted by \"E\" and can be selected with a slider;\n",
    "- _Coefficient of variation_ denoted by \"C.o.V.\" and can be selected with a slider.\n",
    "\n",
    "```{note}\n",
    "To run the interactive reliability prediction on this page, click the {fa}`rocket` --> {guilabel}`Live Code` button on the top of the page. Wait a few seconds until the Kernel has loaded and run the cell below with {guilabel}`Run`.\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f241b1d5-0047-4063-83ac-68b90a366dbf",
   "metadata": {
    "tags": [
     "thebe-init",
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "08223955bd1247a09c3e9eff9ad547a9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "VBox(children=(HBox(children=(VBox(children=(Dropdown(description='Dist D_cr', index=1, layout=Layout(align_it…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "39c641cc1635451b8f455fdcf48d7321",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from nrpmint.booktools import fatigue_failure\n",
    "\n",
    "# start the web user-interface\n",
    "fatigue_failure.web_ui()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42f442db",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "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.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
