|
| 1 | +import numpy as np |
1 | 2 | import pytest |
2 | 3 | import openmdao.api as om |
3 | | -from pytest import approx |
| 4 | +from pytest import approx, fixture |
4 | 5 |
|
5 | 6 | from h2integrate.transporters.pipe import PipePerformanceModel |
6 | 7 |
|
7 | 8 |
|
| 9 | +@fixture |
| 10 | +def plant_config(): |
| 11 | + plant_dict = { |
| 12 | + "plant": { |
| 13 | + "plant_life": 30, |
| 14 | + "simulation": {"n_timesteps": 8760, "dt": 3600}, |
| 15 | + } |
| 16 | + } |
| 17 | + return plant_dict |
| 18 | + |
| 19 | + |
8 | 20 | @pytest.mark.unit |
9 | | -def test_pipe_with_hydrogen(): |
| 21 | +def test_pipe_with_hydrogen(plant_config): |
10 | 22 | """Test the pipe transport with hydrogen as transport_item.""" |
11 | 23 |
|
12 | 24 | # Create the pipe component with hydrogen as transport item |
13 | | - pipe = PipePerformanceModel(transport_item="hydrogen") |
| 25 | + pipe = PipePerformanceModel(plant_config=plant_config, transport_item="hydrogen") |
14 | 26 |
|
15 | 27 | # Create OpenMDAO problem and add the component |
16 | 28 | prob = om.Problem() |
17 | 29 | prob.model.add_subsystem("pipe", pipe, promotes=["*"]) |
18 | 30 |
|
19 | 31 | # Add independent variable component for input |
20 | 32 | ivc = om.IndepVarComp() |
21 | | - ivc.add_output("hydrogen_in", val=10.0, units="kg/s") |
| 33 | + hydrogen_profile = np.full(8760, 10.0) |
| 34 | + ivc.add_output("hydrogen_in", val=hydrogen_profile, units="kg/s") |
22 | 35 | prob.model.add_subsystem("ivc", ivc, promotes=["*"]) |
23 | 36 |
|
24 | 37 | # Setup and run the model |
25 | 38 | prob.setup() |
26 | | - prob.set_val("hydrogen_in", 10.0, units="kg/s") |
| 39 | + prob.set_val("hydrogen_in", val=hydrogen_profile, units="kg/s") |
27 | 40 | prob.run_model() |
28 | 41 |
|
29 | 42 | # Check that output equals input (pass-through pipe with no losses) |
|
0 commit comments