From 96a756f96659873c4f416646fbe7de654bde9d49 Mon Sep 17 00:00:00 2001 From: Dongping Zhu Date: Wed, 25 Jan 2023 22:10:05 -0500 Subject: [PATCH] Updated fdr to fdm --- CHANGELOG.md | 3 +- README.md | 8 +- docs/source/api.rst | 6 +- docs/source/fatigue damage model.rst | 7 ++ docs/source/fatigue damage rule.rst | 7 -- docs/source/index.rst | 2 +- docs/source/moduleApi/fdm.rst | 5 ++ docs/source/moduleApi/fdr.rst | 5 -- ...pynb => fdmPalmgrenMinerDamageModel.ipynb} | 55 +++++++------ src/ffpack/fdm/__init__.py | 1 + .../{fdr/minerRule.py => fdm/minerModel.py} | 28 ++++--- src/ffpack/fdr/__init__.py | 1 - .../test_fdm_minerRule.py} | 82 +++++++++---------- 13 files changed, 106 insertions(+), 104 deletions(-) create mode 100644 docs/source/fatigue damage model.rst delete mode 100644 docs/source/fatigue damage rule.rst create mode 100644 docs/source/moduleApi/fdm.rst delete mode 100644 docs/source/moduleApi/fdr.rst rename docs/source/moduleCookbook/{fdrPalmgrenMinerDamageRule.ipynb => fdmPalmgrenMinerDamageModel.ipynb} (70%) create mode 100644 src/ffpack/fdm/__init__.py rename src/ffpack/{fdr/minerRule.py => fdm/minerModel.py} (78%) delete mode 100644 src/ffpack/fdr/__init__.py rename tests/{fdr/test_fdr_minerRule.py => fdm/test_fdm_minerRule.py} (62%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec589bc..a07a3e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,11 +43,10 @@ All notable changes to this project will be documented in this file. - (rrm) `fosm` was changed to `mvalFOSM` - (rrm) `formHLRF` was changed to `hlrfFORM` - (rrm) `formCOPT` was changed to `coptFORM` +- (fdr) fatigue damage rule was changed to (fdm) fatigue damage model - (utils) `sequencePeakAndValleys` was changed to `sequencePeakValleyFilter` - (utils) `FitterForSnCurve` was changed to `SnCurveFitter` -### Fixed - ## [ 0.3.0 ] - 2023-01-08 ### Added diff --git a/README.md b/README.md index e727965..a2b116e 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,10 @@ See the package document for more details and examples. ## Contents -* Fatigue damage rule - * Palmgren-miner damage rule - * Naive Palmgren-miner damage rule - * Classic Palmgren-miner damage rule +* Fatigue damage model + * Palmgren-miner damage model + * Naive Palmgren-miner damage model + * Classic Palmgren-miner damage model * Load correction and counting * ASTM counting diff --git a/docs/source/api.rst b/docs/source/api.rst index 1673fe8..6b7c886 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -1,12 +1,12 @@ Module API ========== -``fdr`` fatigue damage rule ---------------------------- +``fdm`` fatigue damage model +---------------------------- .. toctree:: :maxdepth: 2 - moduleApi/fdr + moduleApi/fdm ``lcc`` load correction and counting ------------------------------------ diff --git a/docs/source/fatigue damage model.rst b/docs/source/fatigue damage model.rst new file mode 100644 index 0000000..7353721 --- /dev/null +++ b/docs/source/fatigue damage model.rst @@ -0,0 +1,7 @@ +Fatigue damage model ( fdm ) +====================================== + +.. toctree:: + :maxdepth: 2 + + moduleCookbook/fdmPalmgrenMinerDamageModel diff --git a/docs/source/fatigue damage rule.rst b/docs/source/fatigue damage rule.rst deleted file mode 100644 index f51d41d..0000000 --- a/docs/source/fatigue damage rule.rst +++ /dev/null @@ -1,7 +0,0 @@ -Fatigue damage rule ( fdr ) -====================================== - -.. toctree:: - :maxdepth: 2 - - moduleCookbook/fdrPalmgrenMinerDamageRule diff --git a/docs/source/index.rst b/docs/source/index.rst index 66e3b55..df7c1dd 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -48,7 +48,7 @@ Contents :maxdepth: 2 :caption: Cookbook: - fatigue damage rule + fatigue damage model load correction and counting load sequence generator load spectra and matrices diff --git a/docs/source/moduleApi/fdm.rst b/docs/source/moduleApi/fdm.rst new file mode 100644 index 0000000..67140ea --- /dev/null +++ b/docs/source/moduleApi/fdm.rst @@ -0,0 +1,5 @@ +Palmgren-miner damage model +--------------------------- + +.. automodule:: ffpack.fdm.minerModel + :members: diff --git a/docs/source/moduleApi/fdr.rst b/docs/source/moduleApi/fdr.rst deleted file mode 100644 index feac5c0..0000000 --- a/docs/source/moduleApi/fdr.rst +++ /dev/null @@ -1,5 +0,0 @@ -Palmgren-miner damage rule --------------------------- - -.. automodule:: ffpack.fdr.minerRule - :members: diff --git a/docs/source/moduleCookbook/fdrPalmgrenMinerDamageRule.ipynb b/docs/source/moduleCookbook/fdmPalmgrenMinerDamageModel.ipynb similarity index 70% rename from docs/source/moduleCookbook/fdrPalmgrenMinerDamageRule.ipynb rename to docs/source/moduleCookbook/fdmPalmgrenMinerDamageModel.ipynb index 3ae2ba2..8f9cd2d 100644 --- a/docs/source/moduleCookbook/fdrPalmgrenMinerDamageRule.ipynb +++ b/docs/source/moduleCookbook/fdmPalmgrenMinerDamageModel.ipynb @@ -5,7 +5,7 @@ "id": "59a78634-b651-4aca-8d35-9eb18d2d0ebe", "metadata": {}, "source": [ - "## Palmgren-miner damage rule" + "## Palmgren-miner damage model" ] }, { @@ -13,13 +13,13 @@ "id": "829f716d-ed1d-4bb2-80b3-d2cb3f2db4c2", "metadata": {}, "source": [ - "Palmgren-miner damage rule also known as the linear damage rule is one of the famous damage rules used in the engineering field. Based on the Palmgren-miner's rule, the cumulative damage can be expressed by the following equation,\n", + "Palmgren-miner damage model also known as the linear damage model is one of the famous damage models used in the engineering field. Based on the Palmgren-miner's model, the cumulative damage can be expressed by the following equation,\n", "\n", "$$D = \\sum \\frac{C_i}{F_i}$$\n", "\n", "where $C_i$ and $F_i$ are the counting cycles and the failure cycles at a specific load level.\n", "\n", - "In essence, the Palmgren-miner damage rule treats the fatigue damage on different load levels separately. Therefore, the total damage can be calculated by adding the damage from each load level. Although a discrepancy can be found between the experimental results and the Palmgren-miner damage rule, it is still widely used due to its simplicity.\n", + "In essence, the Palmgren-miner damage model treats the fatigue damage on different load levels separately. Therefore, the total damage can be calculated by adding the damage from each load level. Although a discrepancy can be found between the experimental results and the Palmgren-miner damage model, it is still widely used due to its simplicity.\n", "\n", "Reference: \n", "\n", @@ -32,7 +32,7 @@ "id": "3ed8bda0-48fa-4c3f-8f60-11cff92c965e", "metadata": {}, "source": [ - "### Naive Palmgren-miner damage rule" + "### Naive Palmgren-miner damage model" ] }, { @@ -40,9 +40,9 @@ "id": "6fdf4826-ebd3-4447-b70e-20e6525f2073", "metadata": {}, "source": [ - "Function `minerDamageRuleNaive` implements the native Palmgren-miner damage rule.\n", + "Function `minerDamageModelNaive` implements the native Palmgren-miner damage model.\n", "\n", - "The naive Palmgren-miner damage rule refers to the damage calculation directly based on the aforementioned equation. When we know the counting cycles and failure cycles at each level, then the total damage can be calculated by summing the damage from all load levels." + "The naive Palmgren-miner damage model refers to the damage calculation directly based on the aforementioned equation. When we know the counting cycles and failure cycles at each level, then the total damage can be calculated by summing the damage from all load levels." ] }, { @@ -63,10 +63,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on function minerDamageRuleNaive in module ffpack.fdr.minerRule:\n", + "Help on function minerDamageModelNaive in module ffpack.fdm.minerModel:\n", "\n", - "minerDamageRuleNaive(fatigueData)\n", - " Naive Palmgren-miner damage rule directly calcuates the damage results.\n", + "minerDamageModelNaive(fatigueData)\n", + " Naive Palmgren-miner damage model directly calcuates the damage results.\n", " \n", " Parameters\n", " ----------\n", @@ -79,7 +79,7 @@ " Returns\n", " -------\n", " rst: scalar\n", - " Fatigue damage calculated based on the Palmgren-miner rule\n", + " Fatigue damage calculated based on the Palmgren-miner model\n", " \n", " Raises\n", " ------\n", @@ -92,16 +92,16 @@ " \n", " Examples\n", " --------\n", - " >>> from ffpack.fdr import minerDamageRuleNaive\n", + " >>> from ffpack.fdm import minerDamageModelNaive\n", " >>> fatigueData = [ [ 10, 100 ], [ 200, 2000 ] ]\n", - " >>> rst = minerDamageRuleNaive( fatigueData )\n", + " >>> rst = minerDamageModelNaive( fatigueData )\n", "\n" ] } ], "source": [ - "from ffpack.fdr import minerDamageRuleNaive\n", - "help( minerDamageRuleNaive )" + "from ffpack.fdm import minerDamageModelNaive\n", + "help( minerDamageModelNaive )" ] }, { @@ -121,7 +121,7 @@ "source": [ "nmdrFatigueData = [ [ 10, 100 ], [ 200, 2000 ] ]\n", "\n", - "nmdrResults = minerDamageRuleNaive( nmdrFatigueData )" + "nmdrResults = minerDamageModelNaive( nmdrFatigueData )" ] }, { @@ -147,7 +147,7 @@ "id": "81c2578b-63af-4db0-815d-293c7663d1ae", "metadata": {}, "source": [ - "### Classic Palmgren-miner damage rule" + "### Classic Palmgren-miner damage model" ] }, { @@ -155,9 +155,9 @@ "id": "fe2000e7-f368-4788-9e22-d5cd038b85d9", "metadata": {}, "source": [ - "Function `minerDamageRuleClassic` implements the classic Palmgren-miner damage rule.\n", + "Function `minerDamageModelClassic` implements the classic Palmgren-miner damage model.\n", "\n", - "The classic Palmgren-miner damage rule can calculate the total damage based on the experimental SN curve. Since the load level for counting cycles might be unavailable for failure cycles, the experimental SN curve will be fitted first and determine the failure cycles at the same load level.\n", + "The classic Palmgren-miner damage model can calculate the total damage based on the experimental SN curve. Since the load level for counting cycles might be unavailable for failure cycles, the experimental SN curve will be fitted first and determine the failure cycles at the same load level.\n", "\n", "**Notes**\n", "\n", @@ -182,10 +182,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "Help on function minerDamageRuleClassic in module ffpack.fdr.minerRule:\n", + "Help on function minerDamageModelClassic in module ffpack.fdm.minerModel:\n", "\n", - "minerDamageRuleClassic(lccData, snData, fatigueLimit)\n", - " Classical Palmgren-miner damage rule calculates the damage results based on the SN curve.\n", + "minerDamageModelClassic(lccData, snData, fatigueLimit)\n", + " Classical Palmgren-miner damage model calculates the damage results \n", + " based on the SN curve.\n", " \n", " Parameters\n", " ----------\n", @@ -203,7 +204,7 @@ " Returns\n", " -------\n", " rst: scalar\n", - " Fatigue damage calculated based on the Palmgren-miner rule\n", + " Fatigue damage calculated based on the Palmgren-miner model.\n", " \n", " Raises\n", " ------\n", @@ -213,18 +214,18 @@ " \n", " Examples\n", " --------\n", - " >>> from ffpack.fdr import minerDamageRuleClassic\n", + " >>> from ffpack.fdr import minerDamageModelClassic\n", " >>> lccData = [ [ 1, 100 ], [ 2, 10 ] ]\n", " >>> snData = [ [ 10, 3 ], [ 1000, 1 ] ]\n", " >>> fatigueLimit = 0.5\n", - " >>> rst = minerDamageRuleClassic( lccData, snData, fatigueLimit )\n", + " >>> rst = minerDamageModelClassic( lccData, snData, fatigueLimit )\n", "\n" ] } ], "source": [ - "from ffpack.fdr import minerDamageRuleClassic\n", - "help( minerDamageRuleClassic )" + "from ffpack.fdm import minerDamageModelClassic\n", + "help( minerDamageModelClassic )" ] }, { @@ -246,7 +247,7 @@ "cmdrSnData = [ [ 10, 3 ], [ 1000, 1 ] ]\n", "cmdrFatigueLimit = 0.5\n", "\n", - "cmdrResults = minerDamageRuleClassic( cmdrLccData, cmdrSnData, cmdrFatigueLimit )" + "cmdrResults = minerDamageModelClassic( cmdrLccData, cmdrSnData, cmdrFatigueLimit )" ] }, { diff --git a/src/ffpack/fdm/__init__.py b/src/ffpack/fdm/__init__.py new file mode 100644 index 0000000..69ad881 --- /dev/null +++ b/src/ffpack/fdm/__init__.py @@ -0,0 +1 @@ +from .minerModel import * diff --git a/src/ffpack/fdr/minerRule.py b/src/ffpack/fdm/minerModel.py similarity index 78% rename from src/ffpack/fdr/minerRule.py rename to src/ffpack/fdm/minerModel.py index 8b2a201..2301712 100644 --- a/src/ffpack/fdr/minerRule.py +++ b/src/ffpack/fdm/minerModel.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 ''' -Palmgren-Miner damage rule is one of the famous fatigue damage rules for -fatigue estimation. The rule is defined in a simple and intuitive way and +Palmgren-Miner damage model is one of the famous fatigue damage models for +fatigue estimation. The model is defined in a simple and intuitive way and it is very popular now. Reference: Miner, M.A., 1945. Cumulative damage in fatigue. @@ -11,9 +11,9 @@ import numpy as np from ffpack import utils -def minerDamageRuleNaive( fatigueData ): +def minerDamageModelNaive( fatigueData ): ''' - Naive Palmgren-miner damage rule directly calcuates the damage results. + Naive Palmgren-miner damage model directly calcuates the damage results. Parameters ---------- @@ -26,7 +26,7 @@ def minerDamageRuleNaive( fatigueData ): Returns ------- rst: scalar - Fatigue damage calculated based on the Palmgren-miner rule + Fatigue damage calculated based on the Palmgren-miner model Raises ------ @@ -39,9 +39,9 @@ def minerDamageRuleNaive( fatigueData ): Examples -------- - >>> from ffpack.fdr import minerDamageRuleNaive + >>> from ffpack.fdm import minerDamageModelNaive >>> fatigueData = [ [ 10, 100 ], [ 200, 2000 ] ] - >>> rst = minerDamageRuleNaive( fatigueData ) + >>> rst = minerDamageModelNaive( fatigueData ) ''' # Edge case check fatigueData = np.array( fatigueData ) @@ -57,14 +57,16 @@ def minerDamageRuleNaive( fatigueData ): if p[ 1 ] <= 0: raise ValueError( "Failure cycles should be larger than 0" ) if p[ 0 ] > p[ 1 ]: - raise ValueError( "Failure cycles should be larger than or equal counting cycles" ) + raise ValueError( "Failure cycles should be larger than " + "or equal counting cycles" ) return np.sum( fatigueData[ :, 0 ] / fatigueData[ :, 1 ] ) -def minerDamageRuleClassic( lccData, snData, fatigueLimit ): +def minerDamageModelClassic( lccData, snData, fatigueLimit ): ''' - Classical Palmgren-miner damage rule calculates the damage results based on the SN curve. + Classical Palmgren-miner damage model calculates the damage results + based on the SN curve. Parameters ---------- @@ -82,7 +84,7 @@ def minerDamageRuleClassic( lccData, snData, fatigueLimit ): Returns ------- rst: scalar - Fatigue damage calculated based on the Palmgren-miner rule + Fatigue damage calculated based on the Palmgren-miner model. Raises ------ @@ -92,11 +94,11 @@ def minerDamageRuleClassic( lccData, snData, fatigueLimit ): Examples -------- - >>> from ffpack.fdr import minerDamageRuleClassic + >>> from ffpack.fdr import minerDamageModelClassic >>> lccData = [ [ 1, 100 ], [ 2, 10 ] ] >>> snData = [ [ 10, 3 ], [ 1000, 1 ] ] >>> fatigueLimit = 0.5 - >>> rst = minerDamageRuleClassic( lccData, snData, fatigueLimit ) + >>> rst = minerDamageModelClassic( lccData, snData, fatigueLimit ) ''' # Edge case check lccData = np.array( lccData ) diff --git a/src/ffpack/fdr/__init__.py b/src/ffpack/fdr/__init__.py deleted file mode 100644 index af7f635..0000000 --- a/src/ffpack/fdr/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .minerRule import * diff --git a/tests/fdr/test_fdr_minerRule.py b/tests/fdm/test_fdm_minerRule.py similarity index 62% rename from tests/fdr/test_fdr_minerRule.py rename to tests/fdm/test_fdm_minerRule.py index fdaa3e5..1a8e703 100644 --- a/tests/fdr/test_fdr_minerRule.py +++ b/tests/fdm/test_fdm_minerRule.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from ffpack import fdr +from ffpack import fdm import numpy as np import pytest from unittest.mock import patch @@ -8,110 +8,110 @@ ############################################################################### -# Test minerDamageRuleNaive +# Test minerDamageModelNaive ############################################################################### -def test_minerDamageRuleNaive_emptyInput_valueError(): +def test_minerDamageModelNaive_emptyInput_valueError(): fatigueData = [ [ ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleNaive( fatigueData ) + _ = fdm.minerDamageModelNaive( fatigueData ) -def test_minerDamageRuleNaive_oneDimInput_valueError(): +def test_minerDamageModelNaive_oneDimInput_valueError(): fatigueData = [ 1.0, 2.0 ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleNaive( fatigueData ) + _ = fdm.minerDamageModelNaive( fatigueData ) -def test_minerDamageRuleNaive_irregularInput_valueError(): +def test_minerDamageModelNaive_irregularInput_valueError(): fatigueData = [ [ -10, 100 ], [ 200, -2000 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleNaive( fatigueData ) + _ = fdm.minerDamageModelNaive( fatigueData ) fatigueData = [ [ 10, 100 ], [ 0, 0 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleNaive( fatigueData ) + _ = fdm.minerDamageModelNaive( fatigueData ) fatigueData = [ [ 10, 100 ], [ 2001, 2000 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleNaive( fatigueData ) + _ = fdm.minerDamageModelNaive( fatigueData ) -def test_minerDamageRuleNaive_twoPairs_scalarOutput(): +def test_minerDamageModelNaive_twoPairs_scalarOutput(): fatigueData = [ [ 10, 100 ], [ 200, 2000 ] ] - calRst = fdr.minerDamageRuleNaive( fatigueData ) + calRst = fdm.minerDamageModelNaive( fatigueData ) expectedRst = 0.2 np.testing.assert_allclose( calRst, expectedRst ) -def test_minerDamageRuleNaive_threePairs_scalarOutput(): +def test_minerDamageModelNaive_threePairs_scalarOutput(): fatigueData = [ [ 10, 1000 ], [ 200, 20000 ], [ 50, 500 ] ] - calRst = fdr.minerDamageRuleNaive( fatigueData ) + calRst = fdm.minerDamageModelNaive( fatigueData ) expectedRst = 0.12 np.testing.assert_allclose( calRst, expectedRst ) -def test_minerDamageRuleNaive_fourPairs_scalarOutput(): +def test_minerDamageModelNaive_fourPairs_scalarOutput(): fatigueData = [ [ 1, 100 ], [ 2, 2000 ], [ 3, 30 ], [ 4, 40 ] ] - calRst = fdr.minerDamageRuleNaive( fatigueData ) + calRst = fdm.minerDamageModelNaive( fatigueData ) expectedRst = 0.211 np.testing.assert_allclose( calRst, expectedRst ) -def test_minerDamageRuleNaive_fourPairsLargeCounts_scalarOutput(): +def test_minerDamageModelNaive_fourPairsLargeCounts_scalarOutput(): fatigueData = [ [ 50, 100 ], [ 1000, 2000 ], [ 15, 30 ], [ 40, 40 ] ] - calRst = fdr.minerDamageRuleNaive( fatigueData ) + calRst = fdm.minerDamageModelNaive( fatigueData ) expectedRst = 2.5 np.testing.assert_allclose( calRst, expectedRst ) ############################################################################### -# Test minerDamageRuleClassic +# Test minerDamageModelClassic ############################################################################### -def test_minerDamageRuleClassic_emptyInput_valueError(): +def test_minerDamageModelClassic_emptyInput_valueError(): lccData = [ [ ] ] snData = [ [ 10, 5 ], [ 100, 4 ], [ 100000, 1 ] ] fatigueLimit = 0.5 with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) lccData = [ ] snData = [ [ 10, 5 ], [ 100, 4 ], [ 100000, 1 ] ] fatigueLimit = 0.5 with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) -def test_minerDamageRuleClassic_oneDimInput_valueError(): +def test_minerDamageModelClassic_oneDimInput_valueError(): lccData = [ 1.0, 2.0, 3.0 ] snData = [ [ 10, 5 ], [ 100, 4 ], [ 100000, 1 ] ] fatigueLimit = 0.5 with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) -def test_minerDamageRuleClassic_irregularInput_valueError(): +def test_minerDamageModelClassic_irregularInput_valueError(): lccData = [ [ 1, 1000 ], [ -2, 100 ], [ 4, 10 ] ] snData = [ [ 10, 5 ], [ 100000, 1 ] ] fatigueLimit = 0.5 with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) lccData = [ [ 1, 1000 ], [ 2, -100 ], [ 4, 10 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) lccData = [ [ 1, 1000 ], [ 0, 100 ], [ 4, 10 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) lccData = [ [ 1, 1000 ], [ 2, 0 ], [ 4, 10 ] ] with pytest.raises( ValueError ): - _ = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + _ = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) @patch.object( SnCurveFitter, "getN" ) -def test_minerDamageRuleClassic_twoPairs_scalarOutput( mocker ): +def test_minerDamageModelClassic_twoPairs_scalarOutput( mocker ): mocker.side_effect = lambda x: { 1: 1000, 2: 100 }[ x ] @@ -119,64 +119,64 @@ def test_minerDamageRuleClassic_twoPairs_scalarOutput( mocker ): snData = [ [ 10, 3 ], [ 1000, 1 ] ] fatigueLimit = 0.5 - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.2 np.testing.assert_allclose( calRst, expectedRst ) @patch.object( SnCurveFitter, "getN" ) -def test_minerDamageRuleClassic_threePairs_scalarOutput( mocker ): +def test_minerDamageModelClassic_threePairs_scalarOutput( mocker ): mocker.side_effect = lambda x: { 1: 100000, 2: 10000, 3: 1000, 4: 100 }[ x ] lccData = [ [ 1, 1000 ], [ 2, 100 ], [ 4, 10 ] ] snData = [ [ 10, 5 ], [ 100, 4 ], [ 100000, 1 ] ] fatigueLimit = 0.5 - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.12 np.testing.assert_allclose( calRst, expectedRst ) lccData = [ [ 1, 1000 ], [ 3, 100 ], [ 4, 10 ] ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.21 np.testing.assert_allclose( calRst, expectedRst ) lccData = [ [ 1, 1000 ], [ 3, 100 ], [ 4, 100 ] ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 1.11 np.testing.assert_allclose( calRst, expectedRst ) lccData = [ [ 1, 1000 ], [ 3, 1000 ], [ 4, 100 ] ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 2.01 np.testing.assert_allclose( calRst, expectedRst ) @patch.object( SnCurveFitter, "getN" ) -def test_minerDamageRuleClassic_threePairsHighFatigueLimit_scalarOutput( mocker ): +def test_minerDamageModelClassic_threePairsHighFatigueLimit_scalarOutput( mocker ): lccData = [ [ 1, 1000 ], [ 2, 100 ], [ 4, 10 ] ] snData = [ [ 10, 5 ], [ 100, 4 ], [ 100000, 1 ] ] fatigueLimit = 1 mocker.side_effect = lambda x: { 1: -1, 2: 10000, 4: 100 }[ x ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.11 np.testing.assert_allclose( calRst, expectedRst ) fatigueLimit = 2 mocker.side_effect = lambda x: { 1: -1, 2: -1, 4: 100 }[ x ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.1 np.testing.assert_allclose( calRst, expectedRst ) fatigueLimit = 3 mocker.side_effect = lambda x: { 1: -1, 2: -1, 4: 100 }[ x ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0.1 np.testing.assert_allclose( calRst, expectedRst ) fatigueLimit = 4 mocker.side_effect = lambda x: { 1: -1, 2: -1, 4: -1 }[ x ] - calRst = fdr.minerDamageRuleClassic( lccData, snData, fatigueLimit ) + calRst = fdm.minerDamageModelClassic( lccData, snData, fatigueLimit ) expectedRst = 0 np.testing.assert_allclose( calRst, expectedRst )