VeraGridEngine.Devices.Dynamic package

Submodules

VeraGridEngine.Devices.Dynamic.emt_template module

class VeraGridEngine.Devices.Dynamic.emt_template.EmtLazyTemplateBuilder(builder: Callable[[...], EmtModelTemplate], kwargs: Dict[str, Any])[source]

Bases: object

Typed wrapper used to materialize one EMT template lazily.

build() EmtModelTemplate[source]

Materialize the wrapped EMT template.

Returns:

Materialized EMT template.

class VeraGridEngine.Devices.Dynamic.emt_template.EmtModelTemplate(idtag='', name: str = '')[source]

Bases: PointerDeviceParent

This class serves to give flexible access to either a template or a custom model

CLASS_NON_EDITABLE_PROPERTIES = ('idtag', 'diff_changes', 'device_idtag', 'tpe', 'device_name', 'block')
CLASS_PROPERTIES_WITH_PROFILE = {}
CLASS_PROPERTY_DECLARATIONS = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe)
CLASS_PROPERTY_LIST = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe)
CLASS_REGISTERED_PROPERTIES = {'action': prop:action, 'block': prop:block, 'code': prop:code, 'comment': prop:comment, 'device_idtag': prop:device_idtag, 'device_name': prop:device_name, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'name': prop:name, 'rdfid': prop:rdfid, 'tpe': prop:tpe}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:block, prop:tpe)
property block
Returns:

set_lazy_builder(builder: EmtLazyTemplateBuilder) None[source]

Register one lazy EMT template builder.

Parameters:

builder – Lazy builder wrapper.

Returns:

None.

VeraGridEngine.Devices.Dynamic.fmu_template module

class VeraGridEngine.Devices.Dynamic.fmu_template.FmuTemplate(idtag: str = '', name: str = '')[source]

Bases: PointerDeviceParent

Reusable FMU template stored in the VeraGrid catalogue.

The template keeps a symbolic wrapper block plus the serialized FMU runtime configuration that can later be copied into a concrete device.

CLASS_NON_EDITABLE_PROPERTIES = ('idtag', 'diff_changes', 'device_idtag', 'tpe', 'device_name', 'block', 'serialized_config')
CLASS_PROPERTIES_WITH_PROFILE = {}
CLASS_PROPERTY_DECLARATIONS = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe, prop:domain, prop:mode, prop:fmu_relative_path, prop:serialized_config)
CLASS_PROPERTY_LIST = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe, prop:domain, prop:mode, prop:fmu_relative_path, prop:serialized_config)
CLASS_REGISTERED_PROPERTIES = {'action': prop:action, 'block': prop:block, 'code': prop:code, 'comment': prop:comment, 'device_idtag': prop:device_idtag, 'device_name': prop:device_name, 'diff_changes': prop:diff_changes, 'domain': prop:domain, 'fmu_relative_path': prop:fmu_relative_path, 'idtag': prop:idtag, 'mode': prop:mode, 'name': prop:name, 'rdfid': prop:rdfid, 'serialized_config': prop:serialized_config, 'tpe': prop:tpe}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:block, prop:tpe, prop:domain, prop:mode, prop:fmu_relative_path, prop:serialized_config)
property block: Block

Return the symbolic wrapper block stored by the template.

Returns:

Wrapper block.

property domain: FmuTemplateDomain

Return the simulation domain supported by the template.

Returns:

Template domain.

property fmu_relative_path: str

Return the FMU archive path relative to the VeraGrid project.

Returns:

Relative FMU path.

property mode: FmuTemplateMode

Return the FMI execution mode stored by the template.

Returns:

Template execution mode.

property serialized_config: str

Return the serialized FMU runtime configuration payload.

Returns:

Serialized configuration string.

VeraGridEngine.Devices.Dynamic.rms_template module

class VeraGridEngine.Devices.Dynamic.rms_template.RmsModelTemplate(idtag='', name: str = '')[source]

Bases: PointerDeviceParent

This class serves to give flexible access to either a template or a custom model

CLASS_NON_EDITABLE_PROPERTIES = ('idtag', 'diff_changes', 'device_idtag', 'tpe', 'device_name', 'block')
CLASS_PROPERTIES_WITH_PROFILE = {}
CLASS_PROPERTY_DECLARATIONS = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe)
CLASS_PROPERTY_LIST = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:device_idtag, prop:tpe, prop:device_name, prop:block, prop:tpe)
CLASS_REGISTERED_PROPERTIES = {'action': prop:action, 'block': prop:block, 'code': prop:code, 'comment': prop:comment, 'device_idtag': prop:device_idtag, 'device_name': prop:device_name, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'name': prop:name, 'rdfid': prop:rdfid, 'tpe': prop:tpe}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:block, prop:tpe)
property block
Returns:

VeraGridEngine.Devices.Dynamic.var_factory module

class VeraGridEngine.Devices.Dynamic.var_factory.Connection(non_mutable_uid: int, name: str, uid: int)[source]

Bases: object

connection

name
non_mutable_uid
uid
class VeraGridEngine.Devices.Dynamic.var_factory.VarFactory[source]

Bases: EditableDevice

CLASS_NON_EDITABLE_PROPERTIES: Tuple[str, ...] = ('idtag', 'diff_changes')
CLASS_PROPERTIES_WITH_PROFILE: Dict[str, str] = {}
CLASS_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes)
CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes)
CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'action': prop:action, 'code': prop:code, 'comment': prop:comment, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'name': prop:name, 'rdfid': prop:rdfid}
add_connection(var_to_subs: Var, incoming_var: Var)[source]
add_connections(vars_to_subs: List[Var], incoming_vars: List[Var])[source]
add_const(value: float | None = None, uid: int | None = None, name: str = '') Const[source]

Adds a Cont to the class :param value: :param uid: :param name: :return:

add_diff_var(name: str, reference: VarPowerFlowReferenceType | None = None, network_conn: bool = False, shared_reference: str | None | SharedVarReferenceType = None, non_mutable_uid: int | None = None, uid: int | None = None, diff_var: Var | None = None, base_var: Var | None = None) Var[source]

Adds a Diff ver to the class :param name: :param shared_reference: :param non_mutable_uid: :param network_conn: :param uid: :param diff_var: :param base_var: :return:

add_var(name: str, reference: VarPowerFlowReferenceType | None = None, network_conn: bool = False, shared_reference: str | None | SharedVarReferenceType = None, non_mutable_uid: int | None = None, uid: int | None = None, diff_var: Var | None = None, base_var: Var | None = None) Var[source]

Adds a ver to the class :param name: :param shared_reference: :param reference: :param network_conn: :param non_mutable_uid: :param uid: :param diff_var: :param base_var: :return:

connect_variables_by_uid(var_to_subs_non_mutable_uid: int, incoming_var_uid: int, incoming_var_name: str)[source]
create_reference(reference_name: str)[source]
find_var_or_diff_var(var_uid: int | None)[source]
get_connections_dict() Dict[int, List[Connection]][source]
Returns:

Return type:

get_const(uid: int) Const[source]

Gets a Cont from the class :param uid: :return:

get_const_dict() Dict[int, Const][source]
Returns:

get_diff_var(uid: int) Var[source]

Gets a Diff Var from the class :param uid: :return:

get_diff_var_dict() Dict[int, Var][source]
Returns:

get_references_dict() Dict[str, SharedVarReferenceType][source]
Returns:

Return type:

get_unique_template_name(name: str) str[source]

Return one template name that does not collide with existing symbols.

Some EMT builders reserve their symbolic namespace at the template level before any variables are created. When the requested name is still free, this helper returns it unchanged. Otherwise it appends an integer suffix.

Parameters:

name – Requested template name.

Returns:

Collision-free template name.

get_var(uid: int) Var | None[source]

Gets a Var from the class :param uid: :return:

get_vars_dict() Dict[int, Var][source]
Returns:

get_vars_to_save(dev: Any, names: List[str]) List[Var][source]

this function returns a list of variables which names are in names :param dev: :type dev: :param names: :type names: :return: :rtype:

parse_connections_dict(datalist: Dict[int, List[Any]]) None[source]

Parse serialized connections and replay their runtime alias state.

The saved connection table stores the graph that links one incoming variable to one or more substituted variables through their stable non-mutable identities. Rebuilding only the graph is not sufficient for the runtime symbolic system, because fresh GUI-created models also apply UID/name aliasing immediately when the connection is created. The load path must therefore reconstruct the graph first and then replay the same alias propagation so reopened symbolic models behave like newly created ones.

Parameters:

datalist – List of dicts with block_uid -> list of connection dicts.

Returns:

None.

parse_const_dict(data_list: List[Dict[str, Any]])[source]
Parameters:

data_list

Returns:

parse_diff_var_dict(data_list: List[Dict[str, Any]]) None[source]

Parse persisted differential symbolic variables into the factory.

The loader must rebuild each differential variable using the exact symbolic metadata stored in the .veragrid payload. In particular, the power-flow reference has to be converted back to the VarPowerFlowReferenceType enum so downstream EMT connection logic can distinguish branch terminal references such as vf_A and vt_A from bus references such as v_A.

Parameters:

data_list – Serialized differential variable records.

Returns:

None.

parse_references_dict(datalist: List[Dict[str, Any]])[source]

Parse references list into _references_dict and _vars_references_dict.

Parameters:

datalist – List of dicts with β€œtype”, β€œname”, β€œuid” for share_reference.

Returns:

parse_var_dict(data_list: List[Dict[str, Any]])[source]
Parameters:

data_list

Returns:

register_var(dev: Any, var: Var)[source]

Associate a variable with a device :param dev: Device :param var: Variable

remove_connection(var_to_disconnect: Var, outgoing_var: Var)[source]
save_var_in_vars_references_dict(var: Var, reference: str)[source]
property vars_info: Dict[Any, List[Var]]

Module contents