Thermal Engineering Systems in Python (TESPy)
repository·dev·Indexed 19 days ago
https://github.com/oemof/tespyA Python-based simulation toolkit for the design and offdesign simulation of thermal engineering systems, including power plants, heat pumps, and other thermal energy conversion processes. Version 0.11.0 provides tools for modeling component behavior via characteristic lines and maps, importing custom data from JSON, and creating custom components by inheriting from the Component base class.
What's inside TESPy
- TESPy components are the fundamental building blocks used to model thermal engineering systems. This section covers how to use available component classes, specify simple inputs, implement custom values using characteristic lines or maps, and extend the library by implementing custom equations or creating entirely new components.
Overview of TESPy capabilities
devTESPy (Thermal Engineering Systems in Python) is a simulation toolkit for modeling thermal engineering plants, such as power plants (including organic rankine cycles), heat pumps, refrigeration machines, industrial energy balancing, district heating, and HVAC systems.
Key capabilities include:
- Stationary Operation Calculation: Design the process of your plant by calculating stationary states.
- Offdesign Behavior Prediction: Predict how plants behave under different conditions using component characteristics.
- Component-based Modeling: Build models using basic components like turbines, pumps, compressors, heat exchangers, pipes, mixers, and splitters, or advanced components like drums.
- Optimization: Integrate optimization capabilities via an API to
pymoo. - Postprocessing: Perform exergy analysis and fluid property plotting.
- Extensibility: Implement custom components, fluid property formulations, and equations.
Explore TESPy integration workflows
devTESPy can be integrated into various engineering workflows, including:
- Class templates for models: Using class templates to structure thermal models.
- Optimization: Performing optimization tasks, such as optimizing a thermal power plant.
- Model Coupling: Combining TESPy with
oemof-solphfor integrated energy system modeling. - Exergy Analysis: Using
exerpyalongside TESPy for detailed exergy analysis.
New features in TESPy v0.0.3
devVersion 0.0.3 introduced several key features for thermal engineering modeling:
- New Components: Added a stoichiometric combustion chamber.
- Fluid Databases: Added custom fluid databases, specifically optimized for use with the stoichiometric combustion chamber.
- Heat Exchanger Configuration: Added the
val_SI-attributeto datacontainers, allowing users to set ambient temperatures at simple heat exchangers. - Component Physics:
- Added entropy balance for components.
- Added pressure rise vs. flow rate characteristics for the
pumpcomponent. - Added the Hazen-Williams equation for calculating pressure loss in pipes.
- Network Management: Added support for TESPy network import/export functionality.
- Data Management: Added a data container for grouped component properties.
New modeling capabilities in v0.0.5
devVersion 0.0.5 introduced several new features for thermal engineering modeling:
- Motoric Cogeneration Unit: A new component type for modeling cogeneration. Examples are available in the
oemof_examplesrepository. - Variable Efficiency Modeling: Added bus characteristics to allow modeling of variable efficiencies for components like generators, motors, and boilers.
- Compressor Isentropic Efficiency: Isentropic efficiency characteristics can now be linked to the pressure ratio.
- Volumetric Flow: Support for volumetric flow specification has been added.
- Custom Variables: Custom variables can now be used with turbomachines, vessels, simple heat exchangers, pipes, solar collectors, and cogeneration units.
- Motoric Cogeneration Unit: A new component type for modeling cogeneration. Examples are available in the
Replace Bus and ExergyAnalysis with PowerConnections
devThe
BusandExergyAnalysisclasses are deprecated and will be removed in the next major version following v0.9.To model power flows (non-material flows), use the new
PowerConnectionsystem. This streamlines the API by separating material flow connections from power connections.New Power Components:
PowerSourceMotorGeneratorPowerSinkPowerBus
These components can connect to standard components like
Turbine,Compressor,Pump, orSimpleHeatExchangerviaPowerConnectionobjects.Define custom equations with UserDefinedEquation
devTESPy allows users to define custom mathematical relationships between connection parameters using the
tespy.tools.helpers.UserDefinedEquationclass. This is useful for coupling parameters that are not natively linked by standard components, such as relating mass flow values at one point in a network to temperature values at another.To use this feature, you must provide the function and its partial derivatives correctly to ensure the solver can process the equation. For detailed implementation details, refer to the
tespy.tools.helpers.UserDefinedEquationAPI documentation.# Example concept (requires implementation of partial derivatives) from tespy.tools.helpers import UserDefinedEquation # The user defines a function and its partial derivatives to couple parameters # across different parts of the network.Use partload UA modification for MovingBoundaryHeatExchanger
devTheMovingBoundaryHeatExchangerclass now supports a partload UA modification based on the equation described incecchinato2010. This allows for more accurate modeling of heat exchanger performance under varying load conditions.Specify individual design paths for components or connections
devYou can now specify adesign_pathindividually for single connections or specific components within a network. This allows you to load individual design parameters from a different design case than the primary network design case defined in the network's maindesign_path.Perform chemical exergy analysis
devChemical exergy analysis is available for
CombustionChamberandDiabaticCombustionChamber.When using Grassmann exergy flow diagrams, you can now choose to disaggregate exergy flows into their chemical, physical, and massless (e.g., mechanical or electrical power) components. The environment model includes standard chemical exergy data from Ahrendts and Szargut.
Use block-wise solving and debug structural singularities
devTESPy now solves the equation system block-wise by default using Dulmage-Mendelsohn decomposition. This improves efficiency while maintaining robustness.
Key Features:
- Block Solving: Blocks are solved in precedence order. If a block fails, the solver can escalate to a simultaneous solution of the full system. To force simultaneous solving (disabling block-wise), use
nw.solve(mode, block_solve=False). - Debugging Singularities: If a model is structurally singular or under/over-determined, the error messages now name the specific equations and variables. You can inspect the mathematical structure interactively using
Network.print_structural_analysis(). - Handling Variable Composition: Networks with variable fluid composition are currently always solved simultaneously (block-wise solving is planned for future releases).
# Disable block-wise solving if needed nw.solve(mode, block_solve=False) # Inspect structural issues nw.print_structural_analysis()- Block Solving: Blocks are solved in precedence order. If a block fails, the solver can escalate to a simultaneous solution of the full system. To force simultaneous solving (disabling block-wise), use
How to generate stable starting values for complex models
devTESPy automatically generates starting values by propagating known values through components and estimating temperature levels. However, complex models may fail to converge from these automatic values.
Strategy for convergence:
- Simplify the specification: Instead of using complex constraints (like terminal temperature differences), solve the model first using a simpler, more robust set of specifications (e.g., directly imposing saturation temperature levels like
T_deworT_bubble). - Sequential Solving: Since the solver uses the previous solution as the starting point for the next, once the simplified model converges, you can re-impose the original complex specifications and solve again. The primary variables will now have solved values, providing a much better starting point for the Newton solver.
- Simplify the specification: Instead of using complex constraints (like terminal temperature differences), solve the model first using a simpler, more robust set of specifications (e.g., directly imposing saturation temperature levels like