uesgraphs.systemmodels.templates
This module includes the UESModel graph to write Modelica code from uesgraphs
Functions
|
|
|
Classes
|
|
|
A class to extract model information from OpenModelica classes. |
|
A named tuple representing a modelica parameter. |
|
A class to handle templates for model generation with uesgraphs. |
- class uesgraphs.systemmodels.templates.UESTemplates(model_name, model_type, template_path=None)[source]
A class to handle templates for model generation with uesgraphs.
- model_name
Name of the modelica model. (e.g. AixLib.Fluid.DistrictHeatingCooling.Supplies.OpenLoop.SourceIdeal)
- Type:
- call_function(function_string)[source]
Calls function in template .. attribute:: function_string
Name of the function in the .mako file.
- type:
str
- generate_new_template(path_library)[source]
Generates a new template based on parameter and package information of the given class :param path_library: Path to package.mo of the used library (e.g. C:...Aixlibpackage.mo)
or list of paths to multiple used libraries
- render(node_data, i=None, number_of_instances=None, package_name=None)[source]
Write Modelica code for Demands.OpenLoop.HeatPumpCarnot
- classmethod generate_bulk(models_dict: Dict[str, List[str]], library_path: str | List[str], workspace: str | None = None, rigorous: bool = False) Dict[str, str] [source]
Generate multiple templates in bulk.
- Parameters:
models_dict – Dictionary mapping model types to lists of model names. Example: {“Demand”: [“Model1”, “Model2”], “Pipe”: [“Model3”]}
library_path – Path to Modelica library or list of library paths
workspace – Directory for generated templates (optional)
rigorous – If True, auto-overwrite existing templates without confirmation
- Returns:
Dictionary mapping model names to their template paths or error messages
Example
>>> results = UESTemplates.generate_bulk( ... {"Demand": ["AixLib.Fluid.SomeModel"]}, ... "/path/to/aixlib" ... )
- classmethod generate_from_config(config_file: str, library_path: str | List[str] | None = None, **kwargs) Dict[str, str] [source]
Generate templates from JSON configuration file.
- Parameters:
config_file – Path to JSON configuration file
library_path – Path to Modelica library, list of paths, or None for auto-detection
**kwargs – Additional arguments passed to generate_bulk (workspace, rigorous, etc.)
- Returns:
Dictionary mapping model names to template paths or error messages
Example
>>> results = UESTemplates.generate_from_config( ... "data/templates/template_aixlib_components.json" ... )
- class uesgraphs.systemmodels.templates.Parameter(value: Any, type: str, category: str = '', description: str = '', unit: str = '')[source]
A named tuple representing a modelica parameter.
- value
The value of the parameter.
- Type:
Any
- type
The type of the parameter in model. Like Modelica.Units.SI.SpecificHeatCapacity or Boolean
- Type:
- category
The category of the parameter. Either “optional” or “mandatory”. Specified in _extract_parameters. Important for the template generation.
- Type:
str, optional
- description
A brief description of the parameter. Defaults to “”. Not needed yet.
- Type:
str, optional
- unit
The unit of measurement for the parameter. Defaults to “”. Not needed yet.
- Type:
str, optional
Example
>>> param = Parameter(value=42, type="Integer", category="mandatory", ... description="The answer to life, the universe, and everything", ... unit="") >>> print(param.value) 42 >>> print(param.category) mandatory
- class uesgraphs.systemmodels.templates.ModelInfoExtractor(path_library: str, log_level: int = 20)[source]
A class to extract model information from OpenModelica classes.
- list_main_models()[source]
Lists all main models in the loaded library.
This method queries OpenModelica for a list of all main models in the currently loaded library. It returns a list of class names that can be used for further analysis.
Returns:
- List[str]
A list of class names representing the main models in the loaded library.
Notes:
The method logs debug information about the found classes.