From b8a60e5d4586ff1597218348d94c6efd37e6f696 Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Thu, 14 Nov 2024 09:42:27 +0100 Subject: [PATCH] Small docs improvement Signed-off-by: Johannes Mueller --- INSTALLATION.md | 8 +++---- demos/load_collective.ipynb | 45 ++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index 6352fc3c..bb75569c 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -25,7 +25,7 @@ on how to do that. The newly created environment must be activated. The following command lines should do it ``` -conda create -n pylife-env python=3.11 --yes +conda create -n pylife-env python=3.12 --yes conda activate pylife-env ``` @@ -41,7 +41,7 @@ That's not recommended. If you really want to do that, you probably know how to do it. -### pip install +### Install the pyLife package The simplest way to install pyLife is just using the pip package ``` @@ -75,7 +75,7 @@ Create an environment – usually a good idea to use a prefixed environment in your pyLife working directory and activate it. ``` -conda create -p .venv python=3.11 pip --yes +conda create -p .venv python=3.12 pip --yes conda activate ./.venv ``` @@ -94,7 +94,7 @@ pytest If it creates an output ending like below, the installation was successful. ``` -================ 228 passed, 1 deselected, 13 warnings in 30.45s =============== +================ 1171 passed, 7 skipped, 6 deselected, 3 warnings in 23.06s =============== ``` There might be some `DeprecationWarning`s. Ignore them for now. diff --git a/demos/load_collective.ipynb b/demos/load_collective.ipynb index 8ece86da..963f061c 100644 --- a/demos/load_collective.ipynb +++ b/demos/load_collective.ipynb @@ -7,7 +7,7 @@ "source": [ "# Load Collectives and Load Histograms\n", "\n", - "From the load (stress) side pyLife provides the classes `LoadCollective` and `LoadHistogram` to deal with load collectives. `LoadCollective` contains individal hysteresis loops whereas `LoadHistogram` contains a 2D-histogram of classes of hysteresis loops and the number of cycles with which they occur." + "From the load (stress) side pyLife provides the classes [`LoadCollective`](https://pylife.readthedocs.io/en/stable/stress/load_collective.html) and [`LoadHistogram`](https://pylife.readthedocs.io/en/stable/stress/load_histogram.html) to deal with load collectives. `LoadCollective` contains individal hysteresis loops whereas `LoadHistogram` contains a 2D-histogram of classes of hysteresis loops and the number of cycles with which they occur." ] }, { @@ -93,7 +93,7 @@ "id": "31b400a3", "metadata": {}, "source": [ - "As you can see, the rainflow analysis found five histresis loops, three from 1.0 to -1.0 and two from -2.0 to 2.0. Alternatively you can ask the recorder for a load histogram:" + "As you can see, the rainflow analysis found five hystresis loops, three from 1.0 to -1.0 and two from -2.0 to 2.0. Alternatively you can ask the recorder for a load histogram:" ] }, { @@ -293,12 +293,36 @@ "plt.pcolormesh(X, Y, numpy_hist)" ] }, + { + "cell_type": "markdown", + "id": "cf99a42b-3075-42e5-87c3-2d99ab55a681", + "metadata": {}, + "source": [ + "In order to use this load histogram for a damage calculation we can perform a mean stress transformation to transorm all the hysteresis loops to one given R-value." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a0d06dfd-2dd9-4689-b230-67c102220e31", + "metadata": {}, + "outputs": [], + "source": [ + "meanstress_sensitivity = pd.Series({\n", + " 'M': 0.3,\n", + " 'M2': 0.2\n", + "})\n", + "\n", + "transformed_histogram = histogram.meanstress_transform.fkm_goodman(meanstress_sensitivity, R_goal=-1)\n", + "transformed_histogram.to_pandas()" + ] + }, { "cell_type": "markdown", "id": "0f505f1a", "metadata": {}, "source": [ - "We can also plot the cumulated version of the histogram. Therefor we put the amplitude and the cycles into a dataframe." + "We can also plot the cumulated version of the histogram. Therefore we put the amplitude and the cycles into a dataframe." ] }, { @@ -309,8 +333,8 @@ "outputs": [], "source": [ "df = pd.DataFrame({\n", - " 'cycles': histogram.load_collective.cycles, \n", - " 'amplitude': histogram.load_collective.amplitude, \n", + " 'cycles': transformed_histogram.cycles, \n", + " 'amplitude': transformed_histogram.amplitude, \n", "}).sort_values('amplitude', ascending=False)" ] }, @@ -332,6 +356,14 @@ "plt.plot(np.cumsum(df.cycles), df.amplitude)\n", "plt.loglog()" ] + }, + { + "cell_type": "markdown", + "id": "7d3e056d-7579-4fca-bc40-5687f3779eb1", + "metadata": {}, + "source": [ + " " + ] } ], "metadata": { @@ -349,7 +381,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.12.4" } }, "nbformat": 4,