Skip to content

Commit

Permalink
refactor: yaml model class and reader
Browse files Browse the repository at this point in the history
Make YamlModel reusable without having to use files on disk
  • Loading branch information
jsolaas committed Sep 2, 2024
1 parent b1d4e88 commit 50f41ab
Show file tree
Hide file tree
Showing 23 changed files with 406 additions and 220 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ dependencies.

```bash
pip install libecalc[notebooks]
```
```

In the examples you will find examples using both the YAML specifications and Python models. See /examples

Run jupyter:

```bash
jupyter notebook examples
```

## Documentation

The documentation can be found at https://equinor.github.io/ecalc
122 changes: 97 additions & 25 deletions examples/simple_python_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"# Simple Model Example\n",
Expand Down Expand Up @@ -39,7 +42,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"### Python Model\n",
Expand All @@ -65,7 +71,10 @@
"end_time": "2023-04-26T14:25:23.596846Z",
"start_time": "2023-04-26T14:25:23.572924Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -107,6 +116,9 @@
"start_time": "2023-04-26T13:28:02.924970Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"is_executing": true
}
Expand Down Expand Up @@ -305,7 +317,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we create fuel and emissions that will be used by the model."
Expand All @@ -320,6 +335,9 @@
"start_time": "2023-04-26T13:28:02.932398Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"is_executing": true
}
Expand All @@ -337,7 +355,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Next we create the Flare"
Expand All @@ -352,6 +373,9 @@
"start_time": "2023-04-26T13:28:02.934113Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"is_executing": true
}
Expand Down Expand Up @@ -382,7 +406,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we create a gas export compressor"
Expand All @@ -397,6 +424,9 @@
"start_time": "2023-04-26T13:28:02.939094Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"is_executing": true
}
Expand Down Expand Up @@ -439,7 +469,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we create the base production load"
Expand All @@ -453,7 +486,10 @@
"end_time": "2023-04-26T14:25:24.117379Z",
"start_time": "2023-04-26T14:25:24.115645Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -480,7 +516,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we create a gas injection compressor"
Expand All @@ -494,7 +533,10 @@
"end_time": "2023-04-26T14:25:24.120878Z",
"start_time": "2023-04-26T14:25:24.119794Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -550,7 +592,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we create a Produced Water Re-injection Pump"
Expand All @@ -564,7 +609,10 @@
"end_time": "2023-04-26T14:25:24.124429Z",
"start_time": "2023-04-26T14:25:24.123353Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -609,7 +657,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"The we create a Seawater Injection Pump"
Expand All @@ -623,7 +674,10 @@
"end_time": "2023-04-26T14:25:24.127468Z",
"start_time": "2023-04-26T14:25:24.126420Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -661,7 +715,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Then we collect the electricity consumers inside a GeneratorSet"
Expand All @@ -675,7 +732,10 @@
"end_time": "2023-04-26T14:25:24.130979Z",
"start_time": "2023-04-26T14:25:24.129956Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -709,7 +769,10 @@
"end_time": "2023-04-26T14:25:24.134692Z",
"start_time": "2023-04-26T14:25:24.133559Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -741,7 +804,10 @@
"end_time": "2023-04-26T14:25:24.148885Z",
"start_time": "2023-04-26T14:25:24.147857Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -768,7 +834,10 @@
"end_time": "2023-04-26T14:25:24.638557Z",
"start_time": "2023-04-26T14:25:24.153021Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -797,7 +866,10 @@
"end_time": "2023-04-26T14:25:24.640337Z",
"start_time": "2023-04-26T14:25:24.639622Z"
},
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -809,23 +881,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.8.16"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 4
}
Loading

0 comments on commit 50f41ab

Please sign in to comment.