pytrnsys_process.deck package#
Submodules#
pytrnsys_process.deck.extractor module#
- pytrnsys_process.deck.extractor.parse_deck_for_constant_expressions(deck_as_string: str, logger: ~logging.Logger = <Logger default_pytrnsys_process (WARNING)>) dict[str, float | int][source]#
Evaluate constant expressions in a TRNSYS deck file and return their values.
This function parses a TRNSYS deck file string, identifies constant expressions, and evaluates them to their numerical values. It handles mathematical operations, functions, and variable references.
- Parameters:
deck_as_string (str) – A string containing the contents of a TRNSYS deck file.
logger (Logger) – provide your own logger. to for example log per simulation
- Returns:
variable_values – A dictionary mapping variable names to their evaluated values (float or int). The original case of variable names is preserved in the returned dictionary. Expressions that could not be evaluated are not included in the returned dictionary.
- Return type:
- class pytrnsys_process.deck.extractor.EquationsCollectorVisitor[source]#
Bases:
VisitorThis visitor is given the whole deck as a tree. For each equation the equation() method is called and it appends it to a list of equations
- class pytrnsys_process.deck.extractor.EquationsTransformer(evaluated_variables: Mapping[str, float | int])[source]#
Bases:
Transformer
pytrnsys_process.deck.parser module#
- pytrnsys_process.deck.parser.parse_dck(ddck_content: str) Tree[source]#
Parse the provided dck content string and generate a tree structure using the Lark parser.
The function utilizes an internal parser to interpret the given dck_content and produce a parsed tree object. It requires the content to be in a format understood by the parser.
- Parameters:
ddck_content (str) – The string content of the dck file to be parsed.
- Returns:
The parsed tree representation of the provided dck content.
- Return type:
_lark.Tree
- Raises:
Any exceptions raised by the underlying parser. –
pytrnsys_process.deck.visitor_helpers module#
- pytrnsys_process.deck.visitor_helpers.get_child_token_value(token_type: str, tree: Tree, conversion_function: Callable[[str], _T]) _T[source]#
- pytrnsys_process.deck.visitor_helpers.get_child_token_value_or_none(token_type: str, tree: Tree, conversion_function: Callable[[str], _T]) _T | None[source]#
- pytrnsys_process.deck.visitor_helpers.get_child_token_or_none(token_type: str, tree: Tree) Token | None[source]#
Module contents#
- pytrnsys_process.deck.parse_deck_for_constant_expressions(deck_as_string: str, logger: ~logging.Logger = <Logger default_pytrnsys_process (WARNING)>) dict[str, float | int][source]#
Evaluate constant expressions in a TRNSYS deck file and return their values.
This function parses a TRNSYS deck file string, identifies constant expressions, and evaluates them to their numerical values. It handles mathematical operations, functions, and variable references.
- Parameters:
deck_as_string (str) – A string containing the contents of a TRNSYS deck file.
logger (Logger) – provide your own logger. to for example log per simulation
- Returns:
variable_values – A dictionary mapping variable names to their evaluated values (float or int). The original case of variable names is preserved in the returned dictionary. Expressions that could not be evaluated are not included in the returned dictionary.
- Return type: