Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor HCM Rainflow counter #145

Merged
merged 19 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 42 additions & 53 deletions demos/fkm_nonlinear/fkm_nonlinear.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"id": "312c5770",
"metadata": {},
"source": [
"### Run FKM nonlinear algorithm"
"## Run FKM nonlinear algorithm"
]
},
{
Expand All @@ -150,7 +150,7 @@
"id": "941a473e",
"metadata": {},
"source": [
"#### Output resulting lifetimes"
"## Output resulting lifetimes"
]
},
{
Expand Down Expand Up @@ -209,7 +209,7 @@
"id": "165ca7d3",
"metadata": {},
"source": [
"#### Lifetime $N$ for given failure probability $P_A$\n",
"## Lifetime $N$ for given failure probability $P_A$\n",
"The dashed lines show the lifetime if the scaling factor $\\gamma_M$ is not clipped at 1.1 (P_RAM), respective 1.2 (P_RAJ)."
]
},
Expand Down Expand Up @@ -239,7 +239,7 @@
"id": "7c518856",
"metadata": {},
"source": [
"#### Plot failure probability\n",
"## Plot failure probability\n",
"The marked points have $P_A$ = 50%."
]
},
Expand Down Expand Up @@ -274,7 +274,7 @@
"id": "94ac0271",
"metadata": {},
"source": [
"#### Woehler curves"
"## Woehler curves"
]
},
{
Expand Down Expand Up @@ -366,7 +366,7 @@
"id": "2e8a779f",
"metadata": {},
"source": [
"#### Hystereses"
"## Hystereses"
]
},
{
Expand Down Expand Up @@ -398,33 +398,27 @@
"# plot resulting stress-strain curve\n",
"sampling_parameter = 50 # choose larger for smoother plot\n",
"plotting_data = detector.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
" \n",
"primary = plotting_data.loc[~plotting_data.secondary_branch]\n",
"secondary = plotting_data.loc[plotting_data.secondary_branch]\n",
"\n",
"strain_values_primary = plotting_data[\"strain_values_primary\"]\n",
"stress_values_primary = plotting_data[\"stress_values_primary\"]\n",
"hysteresis_index_primary = plotting_data[\"hysteresis_index_primary\"]\n",
"strain_values_secondary = plotting_data[\"strain_values_secondary\"]\n",
"stress_values_secondary = plotting_data[\"stress_values_secondary\"]\n",
"hysteresis_index_secondary = plotting_data[\"hysteresis_index_secondary\"]\n",
"\n",
"sampling_parameter = 50 # choose larger for smoother plot\n",
"plotting_data_1st = detector_1st.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
"\n",
"strain_values_primary_1st = plotting_data_1st[\"strain_values_primary\"]\n",
"stress_values_primary_1st = plotting_data_1st[\"stress_values_primary\"]\n",
"hysteresis_index_primary_1st = plotting_data_1st[\"hysteresis_index_primary\"]\n",
"strain_values_secondary_1st = plotting_data_1st[\"strain_values_secondary\"]\n",
"stress_values_secondary_1st = plotting_data_1st[\"stress_values_secondary\"]\n",
"hysteresis_index_secondary_1st = plotting_data_1st[\"hysteresis_index_secondary\"]\n",
"\n",
"plotting_data_1st = detector.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
" \n",
"primary_1st = plotting_data_1st.loc[~plotting_data_1st.secondary_branch]\n",
"secondary_1st = plotting_data_1st.loc[plotting_data_1st.secondary_branch]\n",
"\n",
"# stress-strain diagram\n",
"axes[1,0].plot(strain_values_primary, stress_values_primary, \"y-\", lw=2, label=\"HCM second run\")\n",
"axes[1,0].plot(strain_values_secondary, stress_values_secondary, \"y-.\", lw=2)\n",
"axes[1,0].plot(strain_values_primary_1st, stress_values_primary_1st, \"g-\", lw=2, label=\"HCM first run\")\n",
"axes[1,0].plot(strain_values_secondary_1st, stress_values_secondary_1st, \"g-.\", lw=2)\n",
"for i, prim in primary.groupby(\"load_segment\"):\n",
" axes[1,0].plot(prim.strain, prim.stress, \"y-\", lw=2, label=\"HCM second run\" if i == 0 else None)\n",
"for _, sec in secondary.groupby(\"load_segment\"):\n",
" axes[1,0].plot(sec.strain, sec.stress, \"y-.\", lw=2)\n",
"for i, prim in primary_1st.groupby(\"load_segment\"):\n",
" axes[1,0].plot(prim.strain, prim.stress, \"g-\", lw=2, label=\"HCM first run\" if i == 0 else None)\n",
"for _, sec in secondary_1st.groupby(\"load_segment\"):\n",
" axes[1,0].plot(sec.strain, sec.stress, \"g-.\", lw=2)\n",
"axes[1,0].grid()\n",
"axes[1,0].set_xlabel(\"$\\epsilon$\")\n",
"axes[1,0].set_ylabel(\"$\\sigma$ [MPa]\")\n",
"axes[1,0].set_xlabel(r\"$\\epsilon$\")\n",
"axes[1,0].set_ylabel(r\"$\\sigma$ [MPa]\")\n",
"axes[1,0].set_title(f\"P_{parameter_name} material response\")\n",
"\n",
"\n",
Expand All @@ -442,32 +436,27 @@
"# plot resulting stress-strain curve\n",
"sampling_parameter = 50 # choose larger for smoother plot\n",
"plotting_data = detector.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
" \n",
"primary = plotting_data.loc[~plotting_data.secondary_branch]\n",
"secondary = plotting_data.loc[plotting_data.secondary_branch]\n",
"\n",
"strain_values_primary = plotting_data[\"strain_values_primary\"]\n",
"stress_values_primary = plotting_data[\"stress_values_primary\"]\n",
"hysteresis_index_primary = plotting_data[\"hysteresis_index_primary\"]\n",
"strain_values_secondary = plotting_data[\"strain_values_secondary\"]\n",
"stress_values_secondary = plotting_data[\"stress_values_secondary\"]\n",
"hysteresis_index_secondary = plotting_data[\"hysteresis_index_secondary\"]\n",
"\n",
"sampling_parameter = 50 # choose larger for smoother plot\n",
"plotting_data_1st = detector_1st.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
"\n",
"strain_values_primary_1st = plotting_data_1st[\"strain_values_primary\"]\n",
"stress_values_primary_1st = plotting_data_1st[\"stress_values_primary\"]\n",
"hysteresis_index_primary_1st = plotting_data_1st[\"hysteresis_index_primary\"]\n",
"strain_values_secondary_1st = plotting_data_1st[\"strain_values_secondary\"]\n",
"stress_values_secondary_1st = plotting_data_1st[\"stress_values_secondary\"]\n",
"hysteresis_index_secondary_1st = plotting_data_1st[\"hysteresis_index_secondary\"]\n",
"plotting_data_1st = detector.interpolated_stress_strain_data(n_points_per_branch=sampling_parameter)\n",
" \n",
"primary_1st = plotting_data_1st.loc[~plotting_data_1st.secondary_branch]\n",
"secondary_1st = plotting_data_1st.loc[plotting_data_1st.secondary_branch]\n",
"\n",
"# stress-strain diagram\n",
"axes[1,1].plot(strain_values_primary, stress_values_primary, \"y-\", lw=2, label=\"HCM second run\")\n",
"axes[1,1].plot(strain_values_secondary, stress_values_secondary, \"y-.\", lw=2)\n",
"axes[1,1].plot(strain_values_primary_1st, stress_values_primary_1st, \"g-\", lw=2, label=\"HCM first run\")\n",
"axes[1,1].plot(strain_values_secondary_1st, stress_values_secondary_1st, \"g-.\", lw=2)\n",
"for i, prim in primary.groupby(\"load_segment\"):\n",
" axes[1,1].plot(prim.strain, prim.stress, \"y-\", lw=2, label=\"HCM second run\" if i == 0 else None)\n",
"for _, sec in secondary.groupby(\"load_segment\"):\n",
" axes[1,1].plot(sec.strain, sec.stress, \"y-.\", lw=2)\n",
"for i, prim in primary_1st.groupby(\"load_segment\"):\n",
" axes[1,1].plot(prim.strain, prim.stress, \"g-\", lw=2, label=\"HCM first run\" if i == 0 else None)\n",
"for _, sec in secondary_1st.groupby(\"load_segment\"):\n",
" axes[1,1].plot(sec.strain, sec.stress, \"g-.\", lw=2)\n",
"axes[1,1].grid()\n",
"axes[1,1].set_xlabel(\"$\\epsilon$\")\n",
"axes[1,1].set_ylabel(\"$\\sigma$ [MPa]\")\n",
"axes[1,1].set_xlabel(r\"$\\epsilon$\")\n",
"axes[1,1].set_ylabel(r\"$\\sigma$ [MPa]\")\n",
"axes[1,1].set_title(f\"P_{parameter_name} material response\")\n",
"\n",
"plt.tight_layout()"
Expand All @@ -478,7 +467,7 @@
"id": "31668d98",
"metadata": {},
"source": [
"#### Damaging effects of hystereses"
"## Damaging effects of hystereses"
]
},
{
Expand Down Expand Up @@ -546,7 +535,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
Loading
Loading