esclab 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. esclab-0.0.1/PKG-INFO +186 -0
  2. esclab-0.0.1/README.md +152 -0
  3. esclab-0.0.1/pyproject.toml +55 -0
  4. esclab-0.0.1/setup.cfg +4 -0
  5. esclab-0.0.1/src/esclab/__init__.py +8 -0
  6. esclab-0.0.1/src/esclab/components/__init__.py +35 -0
  7. esclab-0.0.1/src/esclab/components/brayton_simple.py +123 -0
  8. esclab-0.0.1/src/esclab/components/circuit_elements.py +163 -0
  9. esclab-0.0.1/src/esclab/components/esol_properties.py +215 -0
  10. esclab-0.0.1/src/esclab/components/template_component.py +120 -0
  11. esclab-0.0.1/src/esclab/models/__init__.py +1 -0
  12. esclab-0.0.1/src/esclab/models/sample_air-brayton.py +102 -0
  13. esclab-0.0.1/src/esclab/models/sample_circuit.py +109 -0
  14. esclab-0.0.1/src/esclab/models/sample_circuit_hilopass.py +144 -0
  15. esclab-0.0.1/src/esclab/models/sample_circuit_secsub.py +361 -0
  16. esclab-0.0.1/src/esclab/models/sample_circuit_tee.py +111 -0
  17. esclab-0.0.1/src/esclab/models/sample_dispatch.py +295 -0
  18. esclab-0.0.1/src/esclab/models/sample_lc.py +55 -0
  19. esclab-0.0.1/src/esclab/models/template_model.py +89 -0
  20. esclab-0.0.1/src/esclab/plotting/__init__.py +4 -0
  21. esclab-0.0.1/src/esclab/plotting/network_topology.py +2651 -0
  22. esclab-0.0.1/src/esclab/plotting/online_plotter.py +780 -0
  23. esclab-0.0.1/src/esclab/simulate.py +1342 -0
  24. esclab-0.0.1/src/esclab.egg-info/PKG-INFO +186 -0
  25. esclab-0.0.1/src/esclab.egg-info/SOURCES.txt +27 -0
  26. esclab-0.0.1/src/esclab.egg-info/dependency_links.txt +1 -0
  27. esclab-0.0.1/src/esclab.egg-info/requires.txt +21 -0
  28. esclab-0.0.1/src/esclab.egg-info/top_level.txt +1 -0
  29. esclab-0.0.1/tests/test_network_graph_api.py +85 -0
esclab-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: esclab
3
+ Version: 0.0.1
4
+ Summary: Energy Systems Simulation and Control Lab
5
+ Author-email: Mike Wagner <mjwagner2@wisc.edu>
6
+ License-Expression: LicenseRef-UW-Madison-proprietary-instructional
7
+ Project-URL: Homepage, https://github.com/esclab/esclab
8
+ Project-URL: Issues, https://github.com/esclab/esclab/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Classifier: Topic :: Education
13
+ Requires-Python: >=3.13
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: eeslib>=0.0.5
16
+ Requires-Dist: numpy>=1.21.0
17
+ Requires-Dist: scipy>=1.7.0
18
+ Requires-Dist: CoolProp>=6.4.0
19
+ Requires-Dist: sympy>=1.13.0
20
+ Requires-Dist: gurobipy>=12.0.1
21
+ Requires-Dist: pandas>=1.3.0
22
+ Requires-Dist: matplotlib>=3.10.0
23
+ Requires-Dist: pyqtgraph>=0.14.0
24
+ Requires-Dist: PyQt5>=5.15.11
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
28
+ Requires-Dist: build>=0.10; extra == "dev"
29
+ Requires-Dist: twine>=4.0.0; extra == "dev"
30
+ Requires-Dist: sphinx>=8.2.3; extra == "dev"
31
+ Requires-Dist: sphinx_rtd_theme>=3.0.2; extra == "dev"
32
+ Requires-Dist: sphinx_autodoc_typehints>=3.5.2; extra == "dev"
33
+ Provides-Extra: admin
34
+
35
+ # ESCLAB
36
+ **Engineering Simulation and Control Lab**
37
+
38
+ This software provides an environment for time-series simulation and control of complex multi-component systems. The approach used here relies on iterative (successive substitution) solving to converge on values for a given step, allowing compartmentalization of calculations between individual system components.
39
+
40
+ The simulation is configured and managed in Python scripts.
41
+
42
+ A graphical plotting interface provides real-time simulation results and a network topology rendering tool.
43
+
44
+ The software is structured to support both research and teaching activities and is used in the upper-graduate course "ME 964: Simulation and Optimal Control of Energy Systems" at the University of Wisconsin-Madison.
45
+
46
+ ## Installation
47
+
48
+ 1. Download and install a Python package manager. This program was developed using [miniconda](https://www.anaconda.com/download/success?reg=skipped), and it's recommended for environment creation and maintenance.
49
+
50
+ 2. Download and install [VS Code](https://code.visualstudio.com/download) (or your favorite Python IDE, though VS Code is currently recommended)
51
+
52
+ 3. Open a command console and create a new conda environment. You can call this what you'd like, but I assume the name 'esclab_dev' in the documentation:
53
+
54
+ ```bash
55
+ # Create and activate a new conda environment
56
+ conda create -n esclab_dev python=3.13
57
+ conda activate esclab_dev
58
+ ```
59
+
60
+ ### Installing from source code
61
+
62
+ Use this option when you plan on extending the component or model libraries with code that will closely integrate. This allows direct modification of the ESCLab source code and incorporation of the latest updates that are pushed to the GitHub repository.
63
+
64
+ 4. Change to a convenient location for the repository. A path with no spaces is recommended.
65
+ ```bash
66
+ cd C:\repositories
67
+ ```
68
+
69
+ 5. Collect the ESCLab package source code. If you're using git, clone the repository. Otherwise, you can download and unzip the repository.
70
+ ```bash
71
+ # Clone
72
+ git clone https://github.com/uw-esolab/esclab.git
73
+ ```
74
+
75
+ 6. Install the ESCLab project to the python package you just created.
76
+
77
+ ```bash
78
+ # The -e flag makes the installation editable.
79
+ pip install -e .
80
+ # ESCLab currently requires the most recent version of EESLib (published by uw-esolab).
81
+ # Clone and install the editable version to this conda environment.
82
+ # Make sure C:\repositories is replace with the path to your repository directory.
83
+ pip install -e C:\repositories\eeslib
84
+ # Ensure the editable version is correctly installed in esclab_dev.
85
+ python -c "import eeslib; print(eeslib.__file__)"
86
+ ```
87
+
88
+ ### Installing from the package manager (PyPi)
89
+
90
+ Do this **instead** of the source code option if you're happy with a relatively stable release of the ESCLab core source code and will only be developing models and components for your own use without intending to share them as part of the ESCLab distribution.
91
+
92
+ Following step #3 above:
93
+
94
+ 4. Install the package using `pip`:
95
+ ```bash
96
+ pip install esclab
97
+ ```
98
+
99
+ ## Getting started
100
+
101
+ * Source code for constructing and simulating models is found in the /src/esclab directory
102
+ * Components are defined in the */src/esclab/components* folder
103
+ * Models are defined in the */src/esclab/models* folder
104
+
105
+ To create a new model, prepare one or more component files that contain instance(s) of Component classes that are units in the system you want to model. Connect components together in a *model* file.
106
+
107
+ Templates and examples for *Components* and *Models* are provided in their respective folders.
108
+
109
+ * `template_model.py` provides a template for building new system models
110
+ * `template_component.py` provides a template for a component library
111
+ * `sample_circuit_secsub.py` gives and example of a simple solve loop using successive substitution (no coupled equations)
112
+ * `sample_circuit.py` gives an equivalent example using the coupled equation approach. `sample_circuit_tee.py`, and `sample_circuit_hilopass.py` also give examples of solving coupled equations for increasingly complex topologies.
113
+
114
+ The main calculation and plotting scripts are:
115
+
116
+ * `simulate.py` | core simulation engine
117
+ * `network_topology.py` | tools for detecting, organizing, and rendering coupled network systems
118
+ * `online_plotter.py` | Qt-based window for real-time plotting
119
+
120
+ Definitions:
121
+ | Term | Definition |
122
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
123
+ | Component | Building block for a system model. Components take input and compute output values, and they connect with other components |
124
+ | Model | Collection of one or more components together into a simulated system |
125
+ | Simulation | Time-dependent evaluation of a model |
126
+ | Step | Calculations done at a specific value in time. A simulation contains many steps |
127
+ | Coupled equations | Equations that are designated to be solved together using matrix inversion, outside of the normal successive-substitution method |
128
+ | Absolute tolerance | Absolute difference between connection values on succesive iterations |
129
+ | Relative tolerance | Difference relative to the magnitude of the last connection value |
130
+ | Learning rate | Fraction of the difference between the new and old computed values to apply when iterating |
131
+
132
+ ## Uploading a new version to PyPi (developers only!)
133
+
134
+ To upload a new version of ESCLab to Pypi, follow the steps outlined in the [Python packaging tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/).
135
+
136
+ The preferred packaging tool is `setuptools`.
137
+
138
+ The most relevant steps are as follows:
139
+ 1. Don't forget to update the code version number in `pyproject.toml` and in the `src/__init__.py` file.
140
+ 1. Open a command window and navigate to the `esclab` directory, such as
141
+ ```bash
142
+ cd C:\repositories\esclab
143
+ ```
144
+ 2. Ensure the build and packaging tools are installed in the Conda environment that you're using.
145
+ The preferred method will install a developer tools, including build, pytest, and twine, specified in the pyproject.toml file in the esclab directory:
146
+ ```bash
147
+ pip install .[dev]
148
+ ```
149
+ Alternatively, you can manually install packages:
150
+ ```bash
151
+ python -m pip install --upgrade build
152
+ python -m pip install --upgrade twine
153
+ ```
154
+ 3. Build the Python distributable
155
+ ```bash
156
+ python -m build
157
+ ```
158
+ This should create a folder `dist/` that contains a wheel (.whl) and tar.gz file.
159
+ 4. Upload the file to Pypi. You will need to have first created a username and API token, following the packing tutorial instructions. If uploading to the production server, use the command:
160
+ ```bash
161
+ twine upload dist/*
162
+ ```
163
+
164
+ If using the test server, use the command:
165
+ ```bash
166
+ python -m twine upload --repository testpypi dist/*
167
+ ```
168
+
169
+ 5. To install the package, activate the Conda environment (e.g., `conda activate esclab_dev`), and install.
170
+ If running from the production environment use:
171
+ ```bash
172
+ pip install esclab
173
+ ```
174
+
175
+ If you have previous versions of `esclab` already installed, force use of the most recent version using:
176
+ ```bash
177
+ pip install --force-reinstall --upgrade esclab
178
+ ```
179
+
180
+
181
+ ## Authors
182
+
183
+ Lead author:
184
+ Mike Wagner | Associate Professor, University of Wisconsin-Madison | [GitHub: uw-esolab](https://github.com/uw-esolab/) | [Profile](https://engineering.wisc.edu/directory/profile/mike-wagner/)
185
+
186
+ Contributors:
esclab-0.0.1/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # ESCLAB
2
+ **Engineering Simulation and Control Lab**
3
+
4
+ This software provides an environment for time-series simulation and control of complex multi-component systems. The approach used here relies on iterative (successive substitution) solving to converge on values for a given step, allowing compartmentalization of calculations between individual system components.
5
+
6
+ The simulation is configured and managed in Python scripts.
7
+
8
+ A graphical plotting interface provides real-time simulation results and a network topology rendering tool.
9
+
10
+ The software is structured to support both research and teaching activities and is used in the upper-graduate course "ME 964: Simulation and Optimal Control of Energy Systems" at the University of Wisconsin-Madison.
11
+
12
+ ## Installation
13
+
14
+ 1. Download and install a Python package manager. This program was developed using [miniconda](https://www.anaconda.com/download/success?reg=skipped), and it's recommended for environment creation and maintenance.
15
+
16
+ 2. Download and install [VS Code](https://code.visualstudio.com/download) (or your favorite Python IDE, though VS Code is currently recommended)
17
+
18
+ 3. Open a command console and create a new conda environment. You can call this what you'd like, but I assume the name 'esclab_dev' in the documentation:
19
+
20
+ ```bash
21
+ # Create and activate a new conda environment
22
+ conda create -n esclab_dev python=3.13
23
+ conda activate esclab_dev
24
+ ```
25
+
26
+ ### Installing from source code
27
+
28
+ Use this option when you plan on extending the component or model libraries with code that will closely integrate. This allows direct modification of the ESCLab source code and incorporation of the latest updates that are pushed to the GitHub repository.
29
+
30
+ 4. Change to a convenient location for the repository. A path with no spaces is recommended.
31
+ ```bash
32
+ cd C:\repositories
33
+ ```
34
+
35
+ 5. Collect the ESCLab package source code. If you're using git, clone the repository. Otherwise, you can download and unzip the repository.
36
+ ```bash
37
+ # Clone
38
+ git clone https://github.com/uw-esolab/esclab.git
39
+ ```
40
+
41
+ 6. Install the ESCLab project to the python package you just created.
42
+
43
+ ```bash
44
+ # The -e flag makes the installation editable.
45
+ pip install -e .
46
+ # ESCLab currently requires the most recent version of EESLib (published by uw-esolab).
47
+ # Clone and install the editable version to this conda environment.
48
+ # Make sure C:\repositories is replace with the path to your repository directory.
49
+ pip install -e C:\repositories\eeslib
50
+ # Ensure the editable version is correctly installed in esclab_dev.
51
+ python -c "import eeslib; print(eeslib.__file__)"
52
+ ```
53
+
54
+ ### Installing from the package manager (PyPi)
55
+
56
+ Do this **instead** of the source code option if you're happy with a relatively stable release of the ESCLab core source code and will only be developing models and components for your own use without intending to share them as part of the ESCLab distribution.
57
+
58
+ Following step #3 above:
59
+
60
+ 4. Install the package using `pip`:
61
+ ```bash
62
+ pip install esclab
63
+ ```
64
+
65
+ ## Getting started
66
+
67
+ * Source code for constructing and simulating models is found in the /src/esclab directory
68
+ * Components are defined in the */src/esclab/components* folder
69
+ * Models are defined in the */src/esclab/models* folder
70
+
71
+ To create a new model, prepare one or more component files that contain instance(s) of Component classes that are units in the system you want to model. Connect components together in a *model* file.
72
+
73
+ Templates and examples for *Components* and *Models* are provided in their respective folders.
74
+
75
+ * `template_model.py` provides a template for building new system models
76
+ * `template_component.py` provides a template for a component library
77
+ * `sample_circuit_secsub.py` gives and example of a simple solve loop using successive substitution (no coupled equations)
78
+ * `sample_circuit.py` gives an equivalent example using the coupled equation approach. `sample_circuit_tee.py`, and `sample_circuit_hilopass.py` also give examples of solving coupled equations for increasingly complex topologies.
79
+
80
+ The main calculation and plotting scripts are:
81
+
82
+ * `simulate.py` | core simulation engine
83
+ * `network_topology.py` | tools for detecting, organizing, and rendering coupled network systems
84
+ * `online_plotter.py` | Qt-based window for real-time plotting
85
+
86
+ Definitions:
87
+ | Term | Definition |
88
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
89
+ | Component | Building block for a system model. Components take input and compute output values, and they connect with other components |
90
+ | Model | Collection of one or more components together into a simulated system |
91
+ | Simulation | Time-dependent evaluation of a model |
92
+ | Step | Calculations done at a specific value in time. A simulation contains many steps |
93
+ | Coupled equations | Equations that are designated to be solved together using matrix inversion, outside of the normal successive-substitution method |
94
+ | Absolute tolerance | Absolute difference between connection values on succesive iterations |
95
+ | Relative tolerance | Difference relative to the magnitude of the last connection value |
96
+ | Learning rate | Fraction of the difference between the new and old computed values to apply when iterating |
97
+
98
+ ## Uploading a new version to PyPi (developers only!)
99
+
100
+ To upload a new version of ESCLab to Pypi, follow the steps outlined in the [Python packaging tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/).
101
+
102
+ The preferred packaging tool is `setuptools`.
103
+
104
+ The most relevant steps are as follows:
105
+ 1. Don't forget to update the code version number in `pyproject.toml` and in the `src/__init__.py` file.
106
+ 1. Open a command window and navigate to the `esclab` directory, such as
107
+ ```bash
108
+ cd C:\repositories\esclab
109
+ ```
110
+ 2. Ensure the build and packaging tools are installed in the Conda environment that you're using.
111
+ The preferred method will install a developer tools, including build, pytest, and twine, specified in the pyproject.toml file in the esclab directory:
112
+ ```bash
113
+ pip install .[dev]
114
+ ```
115
+ Alternatively, you can manually install packages:
116
+ ```bash
117
+ python -m pip install --upgrade build
118
+ python -m pip install --upgrade twine
119
+ ```
120
+ 3. Build the Python distributable
121
+ ```bash
122
+ python -m build
123
+ ```
124
+ This should create a folder `dist/` that contains a wheel (.whl) and tar.gz file.
125
+ 4. Upload the file to Pypi. You will need to have first created a username and API token, following the packing tutorial instructions. If uploading to the production server, use the command:
126
+ ```bash
127
+ twine upload dist/*
128
+ ```
129
+
130
+ If using the test server, use the command:
131
+ ```bash
132
+ python -m twine upload --repository testpypi dist/*
133
+ ```
134
+
135
+ 5. To install the package, activate the Conda environment (e.g., `conda activate esclab_dev`), and install.
136
+ If running from the production environment use:
137
+ ```bash
138
+ pip install esclab
139
+ ```
140
+
141
+ If you have previous versions of `esclab` already installed, force use of the most recent version using:
142
+ ```bash
143
+ pip install --force-reinstall --upgrade esclab
144
+ ```
145
+
146
+
147
+ ## Authors
148
+
149
+ Lead author:
150
+ Mike Wagner | Associate Professor, University of Wisconsin-Madison | [GitHub: uw-esolab](https://github.com/uw-esolab/) | [Profile](https://engineering.wisc.edu/directory/profile/mike-wagner/)
151
+
152
+ Contributors:
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "esclab"
7
+ version = "0.0.1"
8
+ authors = [
9
+ { name="Mike Wagner", email="mjwagner2@wisc.edu" },
10
+ ]
11
+ description = "Energy Systems Simulation and Control Lab"
12
+ readme = "README.md"
13
+ requires-python = ">=3.13"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ "Topic :: Scientific/Engineering :: Physics",
18
+ "Topic :: Education",
19
+ ]
20
+ license = "LicenseRef-UW-Madison-proprietary-instructional"
21
+ license-files = ["LICENSE"]
22
+
23
+ dependencies = [
24
+ "eeslib>=0.0.5",
25
+ "numpy>=1.21.0",
26
+ "scipy>=1.7.0",
27
+ "CoolProp>=6.4.0",
28
+ "sympy>=1.13.0",
29
+ "gurobipy>=12.0.1",
30
+ "pandas>=1.3.0",
31
+ "matplotlib>=3.10.0",
32
+ "pyqtgraph>=0.14.0",
33
+ "PyQt5>=5.15.11",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/esclab/esclab"
38
+ Issues = "https://github.com/esclab/esclab/issues"
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
42
+ addopts = "-v"
43
+
44
+ [project.optional-dependencies]
45
+ dev = [
46
+ "pytest>=7.0.0",
47
+ "pytest-cov>=4.0.0",
48
+ "build>=0.10",
49
+ 'twine>=4.0.0',
50
+ "sphinx>=8.2.3",
51
+ "sphinx_rtd_theme>=3.0.2",
52
+ "sphinx_autodoc_typehints>=3.5.2",
53
+ ]
54
+ admin = [
55
+ ]
esclab-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ # This file marks the src directory as a Python package.
2
+ """
3
+ ESCLab: Engineering Simulation and Control Lab
4
+ """
5
+
6
+ __version__ = "0.0.1"
7
+ __author__ = "Mike Wagner"
8
+ __email__ = "mjwagner2@wisc.edu"
@@ -0,0 +1,35 @@
1
+ """
2
+ This file ensures that the component libraries are available for import from the top-level components module.
3
+
4
+ Add new modules to this file using:
5
+ from . import my_component_library
6
+
7
+ And add the module name to __all__ to make it available using the flat import syntax:
8
+ from esclab.components import my_component_library
9
+ or
10
+ from esclab.components import *
11
+
12
+ It's best practice to import the component library as a named item, and then
13
+ reference the components through that namespace to avoid name collisions across libraries. For example:
14
+ import esclab.circuit_elements as ce
15
+ ce.Resistor(...)
16
+
17
+ Import the submodule you need and reference components through it to avoid
18
+ name collisions across libraries:
19
+
20
+ from esclab.components import circuit_elements
21
+ circuit_elements.TeeOut(...)
22
+
23
+ """
24
+
25
+ from . import brayton_simple
26
+ from . import circuit_elements
27
+ from . import esol_properties
28
+ from . import template_component
29
+
30
+ __all__ = [
31
+ "brayton_simple",
32
+ "circuit_elements",
33
+ "esol_properties",
34
+ "template_component"
35
+ ]
@@ -0,0 +1,123 @@
1
+ from esclab.simulate import *
2
+ from eeslib import fluid_properties
3
+ import numpy as np
4
+
5
+ # -------------------------------------------
6
+ class Turbine(Component):
7
+
8
+ eta_s = Component.Parameter(0.9)
9
+ mdot_in = Component.Input()
10
+ T_in = Component.Input()
11
+ P_in = Component.Input()
12
+ h_out = Component.Output()
13
+ T_out = Component.Output()
14
+ P_out = Component.Output()
15
+ mdot_out = Component.Output()
16
+ W = Component.Output()
17
+ fluid = 'Air'
18
+
19
+ def calculate(self):
20
+ self.mdot_out = self.mdot_in
21
+ h_in = fluid_properties.enthalpy(self.fluid, T=self.T_in, P=self.P_in)
22
+ s_in = fluid_properties.entropy(self.fluid, T=self.T_in, P=self.P_in)
23
+ self.P_out = self.P_in / self.model.design.PR
24
+ h_out_s = fluid_properties.enthalpy(self.fluid,P=self.P_out, s=s_in)
25
+ self.h_out = h_in - (h_in-h_out_s)*self.eta_s
26
+ self.T_out = fluid_properties.temperature(self.fluid, P=self.P_out, h=self.h_out)
27
+ self.W = (h_in - self.h_out)*self.mdot_in
28
+ return
29
+
30
+ # -------------------------------------------
31
+ class Compressor(Component):
32
+ eta_s = Component.Parameter(0.85)
33
+ PR = Component.Parameter(3.)
34
+
35
+ mdot_in = Component.Input()
36
+ T_in = Component.Input()
37
+ P_in = Component.Input()
38
+
39
+ h_out = Component.Output()
40
+ T_out = Component.Output()
41
+ P_out = Component.Output()
42
+ mdot_out = Component.Output()
43
+ W = Component.Output()
44
+
45
+ fluid = 'Air'
46
+
47
+ def calculate(self):
48
+ self.mdot_out = self.mdot_in
49
+ h_in = fluid_properties.enthalpy(self.fluid, T=self.T_in, P=self.P_in)
50
+ s_in = fluid_properties.entropy(self.fluid, T=self.T_in, P=self.P_in)
51
+ self.P_out = self.P_in * self.PR
52
+ h_out_s = fluid_properties.enthalpy(self.fluid,P=self.P_out, s=s_in)
53
+ self.h_out = h_in + (h_out_s - h_in)/self.eta_s
54
+ self.T_out = fluid_properties.temperature(self.fluid, P=self.P_out, h=self.h_out)
55
+ self.W = (h_in - self.h_out)*self.mdot_in
56
+ return
57
+
58
+ # -------------------------------------------
59
+ class Combustor(Component):
60
+ mdot_in = Component.Input()
61
+ T_in = Component.Input()
62
+ P_in = Component.Input()
63
+
64
+ h_out = Component.Output()
65
+ T_out = Component.Output()
66
+ P_out = Component.Output()
67
+ mdot_out = Component.Output()
68
+ qdot = Component.Output()
69
+
70
+ def presim_setup(self, **kwargs):
71
+ return super().presim_setup(**kwargs)
72
+
73
+ def calculate(self):
74
+ super().calculate()
75
+ self.mdot_out = self.mdot_in
76
+ self.P_out = self.P_in
77
+ self.T_out = self.model.design.T_turb_in
78
+ h_in = fluid_properties.enthalpy(self.model.design.fluid, T=self.T_in, P=self.P_in)
79
+ self.h_out = fluid_properties.enthalpy(self.model.design.fluid, T=self.T_out, P=self.P_out)
80
+ self.qdot = (self.h_out - h_in)*self.mdot_in
81
+ return
82
+
83
+ # -------------------------------------------
84
+ class Cooler(Component):
85
+ dT_approach = Component.Parameter(20)
86
+
87
+ mdot_in = Component.Input()
88
+ T_in = Component.Input()
89
+ P_in = Component.Input()
90
+ T_amb = Component.Input()
91
+
92
+ h_out = Component.Output()
93
+ T_out = Component.Output()
94
+ P_out = Component.Output()
95
+ mdot_out = Component.Output()
96
+ qdot = Component.Output()
97
+
98
+ def calculate(self):
99
+ self.mdot_out = self.mdot_in
100
+ self.P_out = self.P_in
101
+ h_in = fluid_properties.enthalpy(self.model.design.fluid, T=self.T_in, P=self.P_in)
102
+ self.T_out = self.T_amb + self.dT_approach
103
+ self.h_out = fluid_properties.enthalpy(self.model.design.fluid, P=self.model.design.P_low, T=self.T_out)
104
+ self.qdot = (self.h_out - h_in)*self.mdot_in
105
+ return
106
+
107
+ class Summary(Component):
108
+ W_turbine = Component.Input()
109
+ W_compressor = Component.Input()
110
+ Q_combustor = Component.Input()
111
+ eta_cycle = Component.Output()
112
+
113
+ def calculate(self):
114
+ self.eta_cycle = (self.W_turbine + self.W_compressor)/self.Q_combustor
115
+
116
+ class Weather(Component):
117
+ def presim_setup(self):
118
+ self.T_amb = Component.Output()
119
+ return
120
+
121
+ def calculate(self):
122
+ super().calculate()
123
+ self.T_amb = self.model.design.T_amb + 15*np.sin(self.model.time/1e5/np.pi) + 15*np.sin(self.model.time/1e5/np.pi*2+.5)