uesgraphs.examples.e12_template_generation_example
Comprehensive Mako Template Generation for UESGraphs Modelica Components
This module demonstrates three different approaches to generating Mako templates for AixLib component types, providing a complete learning experience from manual step-by-step generation to automated production workflows.
Template Generation Methods:
Manual Method: Step-by-step individual template generation - Educational approach showing internal workings - Individual UESTemplates instantiation for each model - Custom save paths and immediate testing - Full visibility into the generation process
Bulk Method: Efficient batch generation - Single generate_bulk() call for multiple models - Organized error handling and reporting - Suitable for moderate-scale template generation
Configuration-Driven Method: Production-ready automation - Uses JSON configuration files - Environment variable integration - Rigorous mode for automated overwriting - Ideal for CI/CD and automated workflows
Component Types:
Demand Models: - Variable supply temperature models - Heat pump models with Carnot cycle - Closed-loop DHC substation models - Templates include parameters for temperature differences and nominal conditions
Pipe Models: - Static pipe model - Plug flow pipe models (standard and embedded) - Plug flow pipe with zeta value - DHC pipe models - Templates include thermal and geometric parameters
Supply Models: - Ideal source models for open-loop systems - DHC supply models with heater/cooler/storage - Templates include pressure and temperature parameters
Educational Progression:
This example is designed for researchers and developers who want to understand: - How template generation works internally (Manual Method) - How to efficiently generate multiple templates (Bulk Method) - How to set up automated template generation workflows (Config Method)
Requirements:
AixLib v2.1.0+ library installation
UESGraphs package with systemmodels module
Shapely for geometric operations
Optional: AIXLIB_LIBRARY_PATH environment variable for automated workflows
Usage:
Run the script and select from four demonstration modes: 1. Manual demonstration - See step-by-step template creation 2. Bulk demonstration - See efficient batch processing 3. Config demonstration - See automated configuration-driven generation 4. All methods - Experience the complete progression
Functions
|
Method 2: Bulk template generation |
|
Method 3: Configuration-driven template generation |
|
Method 1: Manual step-by-step template generation |
Get AixLib library path via file dialog |
|
|
Get sample test data for different model types |
Get user's choice for demonstration method |
|
|
Main function with method selection |
- uesgraphs.examples.e12_template_generation_example.get_test_data(model_type: str, model_name: str)[source]
Get sample test data for different model types
- uesgraphs.examples.e12_template_generation_example.demonstrate_manual_generation(path_aixlib: str, workspace: str)[source]
Method 1: Manual step-by-step template generation
This approach shows exactly how template generation works internally. Each template is created individually with full control over the process. This is the best method for learning and debugging.
- uesgraphs.examples.e12_template_generation_example.demonstrate_bulk_generation(path_aixlib: str, workspace: str)[source]
Method 2: Bulk template generation
This approach uses the generate_bulk() method to efficiently create multiple templates with organized error handling. Good for moderate scale template generation.
- uesgraphs.examples.e12_template_generation_example.demonstrate_config_generation(workspace: str)[source]
Method 3: Configuration-driven template generation
This approach uses JSON configuration files and environment variables for fully automated template generation. Ideal for production workflows and CI/CD integration.
- uesgraphs.examples.e12_template_generation_example.get_user_choice()[source]
Get user’s choice for demonstration method