Skip to content

Commit 75e53d8

Browse files
authored
Merge pull request #728 from RHammond2/feature/simplified-imports
Feature: Create Package-Level Imports For Basic Objects
2 parents f626984 + 3c461d7 commit 75e53d8

69 files changed

Lines changed: 113 additions & 125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Rename `n_control_window` to `n_control_window_hours` for unit clarity [PR 712](https://github.com/NatLabRockies/H2Integrate/pull/712)
1919
- Update N2 diagram for demand openloop control from static and outdated to dynamic and interactive [PR 714](https://github.com/NatLabRockies/H2Integrate/pull/714)
2020
- Added basic check of 4-length connections in `technology_interconnections` [PR 720](https://github.com/NatLabRockies/H2Integrate/pull/720)
21+
- Adds `H2IntegrateModel`, `load_yaml`, `write_yaml`, and `write_readable_yaml` as package-level imports [PR 728](https://github.com/NatLabRockies/H2Integrate/pull/728).
2122
- Update N2 diagram for Pyomo heuristic control from static image to dynamic and interactive embedded diagram [PR 726](https://github.com/NatLabRockies/H2Integrate/pull/726)
2223
- Added ability to use timeseries for finance calculations [PR 725](https://github.com/NatLabRockies/H2Integrate/pull/725)
2324

docs/_static/class_hierarchy.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/control/controller_demonstrations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ kernelspec:
1515

1616
```{code-cell} ipython3
1717
from pathlib import Path
18+
1819
from matplotlib import pyplot as plt
19-
from h2integrate.core.h2integrate_model import H2IntegrateModel
20-
from h2integrate import EXAMPLE_DIR
2120
21+
from h2integrate import H2IntegrateModel, EXAMPLE_DIR
2222
```
2323

2424
## Hydrogen Dispatch

docs/control/open-loop_controllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Open `h2i_n2.html` in a browser to explore model groups, components, and variabl
4040
```{code-cell} ipython3
4141
:tags: [remove-input]
4242
43-
from h2integrate.core.h2integrate_model import H2IntegrateModel
43+
from h2integrate import H2IntegrateModel
4444
import openmdao.api as om
4545
import os
4646

docs/demand/demand_demo.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,13 @@ We don't want to send more electricity to the electrolyzer than the electrolyzer
6868
:lines: 112-119
6969
```
7070

71-
72-
7371
We initialize and setup the H2I model
7472

7573
```{code-cell} ipython3
7674
from pathlib import Path
7775
from matplotlib import pyplot as plt
78-
from h2integrate.core.h2integrate_model import H2IntegrateModel
79-
from h2integrate import EXAMPLE_DIR
80-
from h2integrate.core.inputs.validation import load_tech_yaml, load_plant_yaml, load_driver_yaml
76+
77+
from h2integrate import H2IntegrateModel, EXAMPLE_DIR, load_tech_yaml, load_plant_yaml, load_driver_yaml
8178
8279
ex_dir = EXAMPLE_DIR / "13_dispatch_for_electrolyzer"
8380
tech_config = load_tech_yaml(ex_dir / "tech_config.yaml")

docs/misc_resources/turbine_models_library_preprocessing.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ We'll start off by importing the required modules and packages:
3434

3535
```{code-cell} ipython3
3636
import os
37-
import numpy as np
3837
38+
import numpy as np
3939
40-
from h2integrate import EXAMPLE_DIR
41-
from h2integrate.core.file_utils import load_yaml
42-
from h2integrate.core.inputs.validation import load_tech_yaml
40+
from h2integrate import H2IntegrateModel, EXAMPLE_DIR, load_yaml, write_readable_yaml, load_tech_yaml
4341
from h2integrate.preprocess.wind_turbine_file_tools import export_turbine_to_pysam_format
44-
from h2integrate.core.h2integrate_model import H2IntegrateModel
4542
```
4643

4744
Load the tech config file that we want to update the turbine model for:
@@ -126,8 +123,6 @@ print(f"LCOH is ${lcoh[0]:.2f}/kg")
126123
### Option 2: Save new tech_config to file and run H2I from file
127124

128125
```{code-cell} ipython3
129-
from h2integrate.core.file_utils import write_readable_yaml
130-
131126
# Define a new filepath for the updated tech config
132127
tech_config_path_new = EXAMPLE_DIR / "08_wind_electrolyzer" / f"tech_config_{turbine_name}.yaml"
133128

docs/resource/resource_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Resource data for a technology can be set using the `set_val()` command. In the
2020

2121
```python
2222
import pandas as pd
23-
from h2integrate.core.h2integrate_model import H2IntegrateModel
23+
from h2integrate import H2IntegrateModel
2424
# Create an H2I model
2525
h2i = H2IntegrateModel("07_run_of_river.yaml")
2626

docs/user_guide/design_of_experiments_in_h2i.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ Next, we'll import the required models and functions to complete run a successfu
154154
# Import necessary methods and packages
155155
from pathlib import Path
156156
157+
from h2integrate import H2IntegrateModel, load_driver_yaml, write_yaml
157158
from h2integrate.core.file_utils import check_file_format_for_csv_generator, load_yaml
158159
from h2integrate.core.dict_utils import update_defaults
159-
from h2integrate.core.h2integrate_model import H2IntegrateModel
160-
from h2integrate.core.inputs.validation import load_driver_yaml, write_yaml
161160
```
162161

163162
##### Setup and first attempt

docs/user_guide/how_to_run_several_cases_in_sequence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ An example is shown in `run_ammonia_synloop.py`:
4646
from pathlib import Path
4747
4848
from h2integrate.tools.run_cases import modify_tech_config, load_tech_config_cases
49-
from h2integrate.core.h2integrate_model import H2IntegrateModel
49+
from h2integrate import H2IntegrateModel
5050
5151
5252
# Create a H2Integrate model

docs/user_guide/how_to_set_up_an_analysis.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ Use the built-in `create_xdsm()` method to generate a static system diagram from
133133
`technology_interconnections` section of your plant config.
134134

135135
```python
136-
from h2integrate.core.h2integrate_model import H2IntegrateModel
137136
import os
138137

138+
from h2integrate import H2IntegrateModel
139+
139140

140141
# Change to an example directory
141142
os.chdir("../../examples/08_wind_electrolyzer/")
@@ -160,10 +161,12 @@ This creates a PDF named `connections_xdsm.pdf` in your current working director
160161
Use OpenMDAO's `n2` utility to generate an interactive HTML diagram of the full model.
161162

162163
```{code-cell} ipython3
163-
from h2integrate.core.h2integrate_model import H2IntegrateModel
164-
import openmdao.api as om
165164
import os
166165
166+
import openmdao.api as om
167+
168+
from h2integrate import H2IntegrateModel
169+
167170
168171
# Change to an example directory
169172
os.chdir("../../examples/08_wind_electrolyzer/")
@@ -204,17 +207,12 @@ display(
204207
*Figure: Interactive OpenMDAO N2 diagram showing the full model structure and variable connections.*
205208

206209

207-
208210
## Running the analysis
209211

210212
Once you have the config files defined, you can run the analysis using a simple Python script that inputs the top-level config yaml.
211213
Here, we will show a script that runs one of the example analyses included in the H2Integrate package.
212214

213215
```{code-cell} ipython3
214-
from h2integrate.core.h2integrate_model import H2IntegrateModel
215-
import os
216-
217-
218216
# Change the current working directory
219217
os.chdir("../../examples/08_wind_electrolyzer/")
220218

0 commit comments

Comments
 (0)