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 (A string containing the contents of a TRNSYS deck file.)
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.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 (A string containing the contents of a TRNSYS deck file.)
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: