nasa / prog_models

The NASA Prognostic Model Package is a Python framework focused on defining and building models for prognostics (computation of remaining useful life) of engineering systems, and provides a set of prognostics models for select components developed within this framework, suitable for use in prognostics applications for these components.
123 stars 50 forks source link

First draft next_state rewrite [Closes #528] #529

Closed teubert closed 1 year ago

teubert commented 1 year ago

Update integration logic to apply not just in simulation but also directly to the next_state method. Solution developed in collaboration with partners at NGC

github-actions[bot] commented 1 year ago

Thank you for opening this PR. Each PR into dev requires a code review. For the code review, look at the following:

github-actions[bot] commented 1 year ago
Benchmarking Results From: Test Time (s)
import main 0.12800670000000003
import thrown object 0.5039236
model initialization 0.11692790000000008
set noise 0.6561394
simulate 0.29845029999999984
simulate with saving 0.9083781000000002
simulate with saving, dt 1.0303514999999996
simulate with printing results, dt 1.2484652
Plot results 13.8453904
Metrics 0.0404447999999995
Surrogate Model Generation 3.1375607000000016
surrogate sim 0.9988479000000012
surrogate sim, dt 2.884797599999999
To: Test Time (s)
import main 0.12423870000000004
import thrown object 0.4979705000000001
model initialization 0.11581660000000005
set noise 0.6633682999999999
simulate 0.29344059999999983
simulate with saving 0.8986218999999998
simulate with saving, dt 1.0107094000000005
simulate with printing results, dt 1.2339338999999994
Plot results 13.763130700000001
Metrics 0.04086549999999889
Surrogate Model Generation 3.184339699999999
surrogate sim 0.9492772999999985
surrogate sim, dt 2.6157709999999987
codecov-commenter commented 1 year ago

Codecov Report

Merging #529 (a38ecc4) into dev (e440026) will increase coverage by 0.45%. The diff coverage is 94.28%.

@@            Coverage Diff             @@
##              dev     #529      +/-   ##
==========================================
+ Coverage   79.83%   80.28%   +0.45%     
==========================================
  Files          30       30              
  Lines        2405     2394      -11     
==========================================
+ Hits         1920     1922       +2     
+ Misses        485      472      -13     
Impacted Files Coverage Δ
src/prog_models/utils/next_state.py 85.71% <75.00%> (+19.04%) :arrow_up:
src/prog_models/prognostics_model.py 82.15% <100.00%> (+1.02%) :arrow_up:
src/prog_models/utils/parameters.py 83.89% <100.00%> (+1.01%) :arrow_up:
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.13092360000000014
import thrown object 0.5161175
model initialization 0.12543959999999998
set noise 0.6527714
simulate 0.3052907
simulate with saving 0.9671237000000001
simulate with saving, dt 1.0554638
simulate with printing results, dt 1.2694577000000002
Plot results 15.4838351
Metrics 0.035992399999997815
Surrogate Model Generation 3.353527100000001
surrogate sim 1.1233061000000006
surrogate sim, dt 3.032310899999999

To:

Test Time (s)
import main 0.1388876000000001
import thrown object 0.5061643
model initialization 0.12094279999999968
set noise 0.6564076000000001
simulate 0.2927225
simulate with saving 0.9250780000000001
simulate with saving, dt 1.0265113000000006
simulate with printing results, dt 1.2481191000000003
Plot results 15.1934924
Metrics 0.035765899999997686
Surrogate Model Generation 3.4654033999999996
surrogate sim 1.0371306000000011
surrogate sim, dt 2.6992857999999984
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.12914380000000003
import thrown object 0.5168629999999999
model initialization 0.11864049999999993
set noise 0.6465631999999999
simulate 0.30098360000000035
simulate with saving 0.9162909000000004
simulate with saving, dt 1.0402549999999997
simulate with printing results, dt 1.2631626000000002
Plot results 14.426905699999999
Metrics 0.03937919999999906
Surrogate Model Generation 3.2041754000000005
surrogate sim 1.0031914999999998
surrogate sim, dt 2.9119451000000005

To:

Test Time (s)
import main 0.12851669999999982
import thrown object 0.5073858
model initialization 0.1156330000000001
set noise 0.6778632999999998
simulate 0.29491239999999985
simulate with saving 0.9107001000000001
simulate with saving, dt 1.0281861000000005
simulate with printing results, dt 1.2447670999999998
Plot results 14.282758900000001
Metrics 0.041316100000003075
Surrogate Model Generation 3.301729899999998
surrogate sim 0.9554074999999997
surrogate sim, dt 2.6998320999999983
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.13428489999999993
import thrown object 0.5099194
model initialization 0.11681649999999988
set noise 0.6577001
simulate 0.29714609999999997
simulate with saving 0.9160398000000001
simulate with saving, dt 1.0332141
simulate with printing results, dt 1.2459176000000003
Plot results 13.8458492
Metrics 0.039055400000002294
Surrogate Model Generation 3.1535677
surrogate sim 1.0037985999999997
surrogate sim, dt 2.877373800000001

To:

Test Time (s)
import main 0.12417069999999986
import thrown object 0.4980924
model initialization 0.11372389999999988
set noise 0.6672145
simulate 0.2952345000000003
simulate with saving 0.8996561999999999
simulate with saving, dt 1.0148527999999999
simulate with printing results, dt 1.2320034
Plot results 14.0167267
Metrics 0.03926620000000014
Surrogate Model Generation 3.2154709999999973
surrogate sim 0.9426393999999974
surrogate sim, dt 2.6337513
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.1306368
import thrown object 0.5115258999999999
model initialization 0.11845790000000012
set noise 0.6488657999999998
simulate 0.30261919999999964
simulate with saving 0.9235011000000002
simulate with saving, dt 1.0392972000000005
simulate with printing results, dt 1.2667303999999993
Plot results 14.034240400000002
Metrics 0.039782900000002286
Surrogate Model Generation 3.165260400000001
surrogate sim 1.0109411999999978
surrogate sim, dt 2.8886649999999996

To:

Test Time (s)
import main 0.12625390000000003
import thrown object 0.4999005000000001
model initialization 0.11487839999999983
set noise 0.6753005999999997
simulate 0.2944078000000001
simulate with saving 0.9061218000000002
simulate with saving, dt 1.0198920999999999
simulate with printing results, dt 1.2464655999999996
Plot results 13.789777099999998
Metrics 0.040725999999999374
Surrogate Model Generation 3.2292951999999993
surrogate sim 0.9475800999999997
surrogate sim, dt 2.6349038999999976
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.1596951000000002
import thrown object 0.6180734999999999
model initialization 0.14281619999999995
set noise 0.7818288
simulate 0.34913209999999983
simulate with saving 1.0909855
simulate with saving, dt 1.2109568
simulate with printing results, dt 1.4667719999999997
Plot results 17.9908286
Metrics 0.043069899999998995
Surrogate Model Generation 3.809143800000001
surrogate sim 1.2589164000000004
surrogate sim, dt 3.4409224000000016

To:

Test Time (s)
import main 0.16179159999999992
import thrown object 0.6141307000000003
model initialization 0.14053009999999988
set noise 0.7884754999999997
simulate 0.34199259999999976
simulate with saving 1.0778686
simulate with saving, dt 1.2056389999999997
simulate with printing results, dt 1.4548700000000006
Plot results 17.733254
Metrics 0.042984499999999315
Surrogate Model Generation 3.9356255000000004
surrogate sim 1.192753800000002
surrogate sim, dt 3.1188575000000007
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.1287670999999999
import thrown object 0.5077274
model initialization 0.11723260000000013
set noise 0.6454969999999998
simulate 0.3004251
simulate with saving 0.9186763
simulate with saving, dt 1.0338964000000002
simulate with printing results, dt 1.2516575999999997
Plot results 14.375620999999999
Metrics 0.03981989999999769
Surrogate Model Generation 3.214715899999998
surrogate sim 1.0004762000000014
surrogate sim, dt 2.8740935000000007

To:

Test Time (s)
import main 0.12555990000000006
import thrown object 0.5034953
model initialization 0.11789690000000008
set noise 0.6724051000000002
simulate 0.30741340000000017
simulate with saving 0.9290946
simulate with saving, dt 1.0578482
simulate with printing results, dt 1.2813558
Plot results 14.44654
Metrics 0.03833710000000323
Surrogate Model Generation 3.317997599999998
surrogate sim 0.9979011
surrogate sim, dt 2.9038874999999997
github-actions[bot] commented 1 year ago
Benchmarking Results [Update] From: Test Time (s)
import main 0.1292373
import thrown object 0.5041734
model initialization 0.11791770000000001
set noise 0.6607210000000001
simulate 0.2999545000000001
simulate with saving 0.9233837999999999
simulate with saving, dt 1.0368684999999997
simulate with printing results, dt 1.2487874999999997
Plot results 14.3062547
Metrics 0.04068489999999869
Surrogate Model Generation 3.188111899999999
surrogate sim 0.9960124000000015
surrogate sim, dt 2.8851747000000003

To:

Test Time (s)
import main 0.1260254999999999
import thrown object 0.5052970999999999
model initialization 0.1158714999999999
set noise 0.6690423999999999
simulate 0.2957768999999999
simulate with saving 0.9090729
simulate with saving, dt 1.0171052999999999
simulate with printing results, dt 1.2386270000000001
Plot results 14.1460115
Metrics 0.04036509999999893
Surrogate Model Generation 3.2804621999999988
surrogate sim 0.9891135999999996
surrogate sim, dt 2.883273599999999
teubert commented 1 year ago

Looks good! Clever way to implement this. You don't have to do anything for this PR with this comment, but I was browsing the centrifugal pump model and it looks like it is considered a discrete model because of the QLeak state but all the other hidden states are continuous. I'm curious if you have any thoughts on how these integration methods could be utilized in a hybrid model, or if it should just be left up to the person writing their model including the integration method in their next state function.

Thanks @MikeAndSpencer - This is a good question. I don't have a good solution now, but I just opened an issue to explore it more.