Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tutorial' into tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
teubert committed Oct 17, 2024
2 parents 0cfdc66 + 7c71be1 commit 441dcce
Showing 1 changed file with 34 additions and 73 deletions.
107 changes: 34 additions & 73 deletions examples/2024PHMTutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,9 @@
"source": [
"The first component of ProgPy are the **Prognostics Models**. Models describe the behavior of the system of interest and how the state of the system evolves with use. ProgPy includes capability for prognostics models to be [physics-based](https://nasa.github.io/progpy/glossary.html#term-physics-based-model) or [data-driven](https://nasa.github.io/progpy/glossary.html#term-data-driven-model).\n",
"\n",
"ProgPy includes a collection of included models which can be accessed through the `progpy.models` package. The built-in models include: \n",
"- [Battery models](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=the%20following%20sections.-,Battery,-Model%23) - equivalent circuit and electrochemistry\n",
"- [Pump model](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=data%2Drepository/.-,Pump,-Model%23)\n",
"- [Pneumatic Valve](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=publication/260652495_Model%2DBased_Prognostics_With_Concurrent_Damage_Progression_Processes-,Pneumatic%20Valve,-%23)\n",
"- [DC Motor](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=article/view/1359-,DC%20Motor,-%23)\n",
"- [Electronic Speed Controller (ESC)](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=%29%20%E2%80%93%20Initial%20state-,ESC,-%23)\n",
"- [Powertrain](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=gov/citations/20200000579-,Powertrain%23,-class%20progpy.models)\n",
"- [Propeller Load](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=motor.paramters%2C%20respectively.-,PropellerLoad,-%23)\n",
"- [Aircraft Models](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#:~:text=t_l%3A%20Load%20Torque-,Aircraft%20Models,-%23)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"All prognostics models have the same [format](https://nasa.github.io/progpy/prog_models_guide.html#modeling-and-sim-guide:~:text=the%20below%20sections-,ProgPy%20Prognostic%20Model%20Format,-%23) within ProgPy. The architecture requires definition of model inputs, states, outputs, and events which come together to create a system model.\n",
"All prognostics models have the same [format](https://nasa.github.io/progpy/prog_models_guide.html#progpy-prognostic-model-format) within ProgPy. The architecture requires definition of model inputs, states, outputs, and events which come together to create a system model.\n",
"\n",
"![next state](img/next_state.png)\n",
"![dx](img/dx.png)"
"ProgPy includes a collection of [included models](https://nasa.github.io/progpy/api_ref/progpy/IncludedModels.html#included-models) which can be accessed through the `progpy.models` package.\n"
]
},
{
Expand Down Expand Up @@ -239,7 +223,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Model parameters describe the specific system the model will simulate. For the Electrochemistry model, the default model parameters are for 18650-type Li-ion battery cells. All parameters can be accessed through `batt.parameters`. Let's print out the battery's capacity, denoted as `qMax` in this model."
"Model parameters describe the specific system the model will simulate. For the Electrochemistry model, the default model parameters are for 18650-type Li-ion battery cells. All parameters can be accessed through `batt.parameters`. Let's print out all of the parameters, followed by the specific parameter for the battery's capacity, denoted as `qMax` in this model."
]
},
{
Expand All @@ -248,7 +232,8 @@
"metadata": {},
"outputs": [],
"source": [
"print(batt.parameters['qMax'])"
"print(batt.parameters)\n",
"print(batt['qMax'])"
]
},
{
Expand All @@ -264,8 +249,8 @@
"metadata": {},
"outputs": [],
"source": [
"batt.parameters['qMax'] = 127000\n",
"print(batt.parameters['qMax'])"
"batt['qMax'] = 127000\n",
"print(batt['qMax'])"
]
},
{
Expand Down Expand Up @@ -314,62 +299,15 @@
" values={'i': [2, 1, 4, 2, 3]})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With this, we are ready to simulate. There are two ways to simulate in ProgPy: 1) simulate to a specific time using `simulate_to()`, and 2) simulate until a particular event occurs, using `simulate_to_threshold()`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Simulate to Time*\n",
"\n",
"To simply simulate the model to a particular time, we can use ProgPy's `simulate_to()` method, which takes input of the time to simulate to and the future_loading function. We'll simulate our battery forward in time for 3000 seconds and save the results every 50 seconds, as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"time_to_simulate_to = 3000\n",
"sim_config = {\n",
" 'save_freq': 50, \n",
"}\n",
"\n",
"results = batt.simulate_to(time=time_to_simulate_to, future_loading_eqn=future_loading,**sim_config)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can plot the results to visualize the simulation. \n",
"<span style=\"color:red\"> Include description of results or just discuss verbally during tutorial? Also - why is one of these plots plotted twice? </span>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"results.inputs.plot(ylabel='Current drawn (amps)')\n",
"results.event_states.plot(ylabel='Battery State of Charge')\n",
"results.outputs.plot(ylabel= {'v': \"voltage (V)\", 't': 'temperature (°C)'}, compact= False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Simulate to Threshold*\n",
"\n",
"Physical systems frequently have one or more failure modes, and there's often a need to predict the progress towards these events and the eventual failure of the system. ProgPy generalizes this concept of predicting Remaining Useful Life (RUL) with [events](https://nasa.github.io/progpy/prog_models_guide.html#modeling-and-sim-guide:~:text=Events,-%23) and their corresponding [thresholds](https://nasa.github.io/progpy/glossary.html#term-threshold) under which they occur. \n",
"With this in mind, we're ready to simulate our model forward in time using ProgPy's [simulation functionality](https://nasa.github.io/progpy/prog_models_guide.html#simulation).\n",
"\n",
"Physical systems frequently have one or more failure modes, and there's often a need to predict the progress towards these events and the eventual failure of the system. ProgPy generalizes this concept of predicting Remaining Useful Life (RUL) with [events](https://nasa.github.io/progpy/prog_models_guide.html#events) and their corresponding thresholds at which they occur. \n",
"\n",
"\n",
"Often, there is interest in simulating a system forward in time until a particular event occurs. ProgPy includes this capability with `simulate_to_threshold()`. "
Expand Down Expand Up @@ -445,13 +383,20 @@
"results.outputs.plot(ylabel= {'v': \"voltage (V)\", 't': 'temperature (°C)'}, compact= False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to simulating to threshold, ProgPy also includes a simpler capability to simulate until a particular time, using `simulate_to()`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Noise\n",
"\n",
"A key factor in modeling any real-world application is noise. See the ProgPy [noise documentation](https://nasa.github.io/progpy/prog_models_guide.html#:~:text=Noise,-%23) for a detailed description of different types of noise and how to include it in the ProgPy architecture. "
"A key factor in modeling any real-world application is noise. See the ProgPy [noise documentation](https://nasa.github.io/progpy/prog_models_guide.html#noise) for a detailed description of different types of noise and how to include it in the ProgPy architecture. "
]
},
{
Expand All @@ -462,6 +407,22 @@
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<span style=\"color:red\">\n",
"https://nasa.github.io/progpy/prog_algs_guide.html#state-estimation-and-prediction-guide\n",
"\n",
"Note to go to documentation \n",
"\n",
"- download data from real datasets (from dataset.py)\n",
"- each dataset split into many runs; string together a bunch and take this as a single run \n",
"- Plot what load looks like; run through state estimation and prediction and compare to data \n",
"- play around with uncertainty to get bounds right\n",
"</span> "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 441dcce

Please sign in to comment.