trnsystor.deck.Deck

class trnsystor.deck.Deck(name, author=None, date_created=None, control_cards=None, models=None, canvas_width=1200, canvas_height=1000)[source]

Deck class.

The Deck class holds TrnsysModel objects, the ControlCards and specifies the name of the project. This class handles reading from a file (see read_file()) and printing to a file (see save()).

Initialize a Deck object.

Parameters
  • name (str) – The name of the project.

  • author (str) – The author of the project.

  • date_created (str) – The creation date. If None, defaults to datetime.datetime.now().

  • control_cards (ControlCards, optional) – The ControlCards. See ControlCards for more details.

  • models (list or trnsystor.collections.components.ComponentCollection) – A list of Components (TrnsysModel, EquationCollection, etc.). If a list is passed, it is converted to a ComponentCollection. name (str): A name for this deck. Could be the name of the project.

Returns

The Deck object.

Return type

Deck

classmethod read_file(file, author=None, date_created=None, proforma_root=None)[source]

Returns a Deck from a file.

Parameters
  • file (str or Path) – Either the absolute or relative path to the file to be opened.

  • author (str) – The author of the project.

  • date_created (str) – The creation date. If None, defaults to datetime.datetime.now().

  • proforma_root (str) – Either the absolute or relative path to the folder where proformas (in xml format) are stored.

property graph

Return the MultiDiGraph of self.

check_deck_integrity()[source]

Checks if Deck definition passes a few obvious rules.

update_models(amodel)[source]

Update the models attribute with a TrnsysModel (or list).

Parameters

amodel (Component or list of Component) –

Returns

None.

remove_models(amodel)[source]

Remove amodel from self.models.

to_file(path_or_buf, encoding=None, mode='w')[source]

Save the Deck object to file.

Examples

>>> from trnsystor.deck import Deck
>>> deck = Deck("Unnamed")
>>> deck.to_file("my_project.dck",None,"w")
Parameters
  • path_or_buf (Union[str, Path, IO[AnyStr]]) – str or file handle, default None File path or object, if None is provided the result is returned as a string. If a file object is passed it should be opened with newline=’’, disabling universal newlines.

  • encoding (str or None) – Encoding to use.

  • mode (str) – Mode to open path_or_buf with.

save(path_or_buf, encoding=None, mode='w')[source]

Save Deck to file.

See to_file()

return_equation_or_constant(name)[source]

Return Equation or Constant for name.

If name parses to int literal, then the int is returned.

static set_typevariable(dck, i, model, tvar, key)[source]

Set the value to the TypeVariable.

Parameters
  • dck (Deck) – the Deck object.

  • i (int) – the idx of the TypeVariable.

  • model (Component) – the component to modify.

  • tvar (str or float) – the new value to set.

  • key (str) – the specific type of TypeVariable, eg.: ‘inputs’, ‘parameters’, ‘outputs’, ‘initial_input_values’.