Thermal Engineering Systems in Python (TESPy)

repository·dev·Indexed 19 days ago

https://github.com/oemof/tespy

A 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.

Tokens
86.1K
Snippets
228
Records
418
Agent score
61%

What's inside TESPy

  1. Overview of TESPy components and customization

    dev
    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.
  2. Overview of TESPy capabilities

    dev

    TESPy (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.
  3. Explore TESPy integration workflows

    dev

    TESPy 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-solph for integrated energy system modeling.
    • Exergy Analysis: Using exerpy alongside TESPy for detailed exergy analysis.
  4. New features in TESPy v0.0.3

    dev

    Version 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-attribute to 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 pump component.
      • 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.
  5. New modeling capabilities in v0.0.5

    dev

    Version 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_examples repository.
    • 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.
  6. Replace Bus and ExergyAnalysis with PowerConnections

    dev

    The Bus and ExergyAnalysis classes are deprecated and will be removed in the next major version following v0.9.

    To model power flows (non-material flows), use the new PowerConnection system. This streamlines the API by separating material flow connections from power connections.

    New Power Components:

    • PowerSource
    • Motor
    • Generator
    • PowerSink
    • PowerBus

    These components can connect to standard components like Turbine, Compressor, Pump, or SimpleHeatExchanger via PowerConnection objects.

  7. Define custom equations with UserDefinedEquation

    dev

    TESPy allows users to define custom mathematical relationships between connection parameters using the tespy.tools.helpers.UserDefinedEquation class. 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.UserDefinedEquation API 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.
  8. Use partload UA modification for MovingBoundaryHeatExchanger

    dev
    The MovingBoundaryHeatExchanger class now supports a partload UA modification based on the equation described in cecchinato2010. This allows for more accurate modeling of heat exchanger performance under varying load conditions.
  9. Specify individual design paths for components or connections

    dev
    You can now specify a design_path individually 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 main design_path.
  10. Perform chemical exergy analysis

    dev

    Chemical exergy analysis is available for CombustionChamber and DiabaticCombustionChamber.

    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.

  11. Use block-wise solving and debug structural singularities

    dev

    TESPy 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()
  12. How to generate stable starting values for complex models

    dev

    TESPy 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:

    1. 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_dew or T_bubble).
    2. 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.