VeraGridEngine.Templates.Emt packageο
Submodulesο
VeraGridEngine.Templates.Emt.arbitrary_source_emt_template moduleο
- class VeraGridEngine.Templates.Emt.arbitrary_source_emt_template.ArbitraryWaveformCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.arbitrary_source_emt_template.ArbitraryWaveformVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.arbitrary_source_emt_template.get_arbitrary_waveform_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, time_points: Sequence[float] = (0.0, 0.02, 0.04), value_points: Sequence[float] = (0.0, 1.0, 0.0), name: str | None = 'arbitrary_waveform_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT current source driven by one arbitrary time waveform.
The same time/value waveform is applied to every active phase.
- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
time_points β Strictly increasing waveform times in seconds.
value_points β Matching waveform values.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.arbitrary_source_emt_template.get_arbitrary_waveform_voltage_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, time_points: Sequence[float] = (0.0, 0.02, 0.04), value_points: Sequence[float] = (0.0, 1.0, 0.0), source_conductance_value: float = 100.0, name: str | None = 'arbitrary_waveform_voltage_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT voltage source driven by one arbitrary time waveform.
The same time/value waveform is applied to every active phase and injected as one Norton equivalent
i = g * (v_src - v_bus).- Parameters:
vf β variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
time_points β Strictly increasing waveform times in seconds.
value_points β Matching waveform values.
source_conductance_value β Norton conductance.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.balanced_source_emt_template moduleο
- class VeraGridEngine.Templates.Emt.balanced_source_emt_template.Balanced3phCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.balanced_source_emt_template.Balanced3phVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.balanced_source_emt_template.ControlledBalanced3phCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.balanced_source_emt_template.ControlledBalanced3phVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.balanced_source_emt_template.get_balanced_3ph_current_source_emt_template(vf: VarFactory, amplitude_value: float = 1.0, frequency_hz: float = 50.0, phase_a_deg: float = 0.0, offset_value: float = 0.0, name: str = 'balanced_3ph_current_source_emt') EmtModelTemplate[source]ο
Build one balanced three-phase sinusoidal EMT current source.
- Parameters:
vf β EMT variable factory.
amplitude_value β Common phase amplitude.
frequency_hz β Common sinusoidal frequency.
phase_a_deg β Phase-A angle offset in degrees.
offset_value β Common phase offset.
name β Symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.balanced_source_emt_template.get_balanced_3ph_voltage_source_emt_template(vf: VarFactory, amplitude_value: float = 1.0, frequency_hz: float = 50.0, phase_a_deg: float = 0.0, offset_value: float = 0.0, source_conductance_value: float = 100.0, name: str = 'balanced_3ph_voltage_source_emt') EmtModelTemplate[source]ο
Build one balanced three-phase sinusoidal EMT voltage source using one Norton equivalent.
- Parameters:
vf β EMT variable factory.
amplitude_value β Common phase amplitude.
frequency_hz β Common sinusoidal frequency.
phase_a_deg β Phase-A angle offset in degrees.
offset_value β Common phase offset.
source_conductance_value β Norton conductance.
name β Symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.balanced_source_emt_template.get_controlled_balanced_3ph_current_source_emt_template(vf: VarFactory, frequency_hz: float = 50.0, phase_a_deg: float = 0.0, offset_value: float = 0.0, name: str = 'controlled_balanced_3ph_current_source_emt') EmtModelTemplate[source]ο
Build one balanced three-phase sinusoidal EMT current source with amplitude command.
- Parameters:
vf β EMT variable factory.
frequency_hz β Common sinusoidal frequency.
phase_a_deg β Phase-A angle offset in degrees.
offset_value β Common phase offset.
name β Symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.balanced_source_emt_template.get_controlled_balanced_3ph_voltage_source_emt_template(vf: VarFactory, frequency_hz: float = 50.0, phase_a_deg: float = 0.0, offset_value: float = 0.0, source_conductance_value: float = 100.0, name: str = 'controlled_balanced_3ph_voltage_source_emt') EmtModelTemplate[source]ο
Build one balanced three-phase sinusoidal EMT voltage source with amplitude command.
- Parameters:
vf β EMT variable factory.
frequency_hz β Common sinusoidal frequency.
phase_a_deg β Phase-A angle offset in degrees.
offset_value β Common phase offset.
source_conductance_value β Norton conductance.
name β Symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.bergeron_line_emt_template moduleο
- class VeraGridEngine.Templates.Emt.bergeron_line_emt_template.BergeronHistoryRuntime(line: Any, line_block: Block, h: float, sbase: float, fbase: float)[source]ο
Bases:
objectRuntime companion for a Bergeron line in reduced active-phase space.
- Gc_redο
- H_redο
- Ih_fο
- Ih_tο
- active_ph: List[str]ο
- bind_terminals(v_f_vars: List[Any], v_t_vars: List[Any]) None[source]ο
Bind the bus terminal voltage variables for the active phases only.
Every active line phase must be present in both terminal bus models. Missing voltages are treated as a topology/model consistency error.
- blockο
- buf_ifο
- buf_itο
- buf_vfο
- buf_vtο
- hο
- hist_Ih_f: List[ndarray]ο
- hist_Ih_f_next: List[ndarray]ο
- hist_Ih_t: List[ndarray]ο
- hist_Ih_t_next: List[ndarray]ο
- hist_if: List[ndarray]ο
- hist_it: List[ndarray]ο
- idx_p_hfο
- idx_p_htο
- idx_vfο
- idx_vtο
- initialize_buffers_from_initial_point(v_f0_red: ndarray, v_t0_red: ndarray, i_f0_red: ndarray, i_t0_red: ndarray) None[source]ο
Fill all delay buffers with the initial steady-state point.
- lineο
- m: intο
- n_delayο
- ph_labelsο
- ph_maskο
- phase_idx: List[int]ο
- setup_indices(uid2idx_vars: dict, uid2idx_event_params: dict, params_offset: int = 0) None[source]ο
- v_f_varsο
- v_t_varsο
- class VeraGridEngine.Templates.Emt.bergeron_line_emt_template.BergeronLineEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.bergeron_line_emt_template.get_bergeron_line_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, name: str | None = 'Bergeron') EmtModelTemplate[source]ο
Create the symbolic EMT template for a Bergeron line.
Only active phases in NABC are represented. The history terms are modelled as runtime-updated event parameters. :param vf: EMT variable factory. :param phN: Bool. True if the line has neutral, else False. :param phA: Bool. True if the line has phase A, else False. :param phB: Bool. True if the line has phase B, else False. :param phC: Bool. True if the line has phase C, else False. :param name: Symbolic model name. :return: EMT bergeron-line model template.
VeraGridEngine.Templates.Emt.bergeron_line_symbolic_runtime moduleο
- class VeraGridEngine.Templates.Emt.bergeron_line_symbolic_runtime.BergeronHistorySymbolicRuntime(line: Any, line_block: Any, h: float, sbase: float, fbase: float)[source]ο
Bases:
BergeronHistoryRuntimeSymbolic helper for Bergeron history runtime.
This class reuses the existing numerical setup (phase reduction, Gc/H matrices, indexing) and exposes symbolic-friendly builders for:
branch nodal injections
history recursion update expressions
- bind_symbolic_state(v_f_tau: List[Any], v_t_tau: List[Any], i_f_tau: List[Any], i_t_tau: List[Any], ih_f: List[Any], ih_t: List[Any]) None[source]ο
Bind reduced-phase symbolic vectors used by symbolic update/injection builders.
- Parameters:
v_f_tau β Delayed from-side voltages in reduced active-phase ordering.
v_t_tau β Delayed to-side voltages in reduced active-phase ordering.
i_f_tau β Delayed from-side currents in reduced active-phase ordering.
i_t_tau β Delayed to-side currents in reduced active-phase ordering.
ih_f β Current from-side Bergeron history terms in reduced active-phase ordering.
ih_t β Current to-side Bergeron history terms in reduced active-phase ordering.
- Returns:
None.
- get_symbolic_injections(v_f_vars: List[Any] | None = None, v_t_vars: List[Any] | None = None, ih_f_vars: List[Any] | None = None, ih_t_vars: List[Any] | None = None) Tuple[List[Any], List[Any]][source]ο
Build Bergeron nodal current injections in full NABC shape.
- Equations per active phase k:
i_f[k] = sum_j Gc[k, j] * v_f[j] + Ih_f[k] i_t[k] = sum_j Gc[k, j] * v_t[j] + Ih_t[k]
- Parameters:
v_f_vars β Active-phase from-side voltages (reduced ordering).
v_t_vars β Active-phase to-side voltages (reduced ordering).
ih_f_vars β Active-phase from-side history terms (reduced ordering).
ih_t_vars β Active-phase to-side history terms (reduced ordering).
- Returns:
Two lists (i_f_full, i_t_full) in full NABC layout using None on missing phases.
- get_symbolic_update(v_f_tau: List[Any] | None = None, v_t_tau: List[Any] | None = None, i_f_tau: List[Any] | None = None, i_t_tau: List[Any] | None = None) Tuple[List[Any], List[Any]][source]ο
Build symbolic expressions for next Bergeron history terms.
This mirrors the existing numerical update in
update_historybut accepts symbolic variables/expressions at delayed time tau:X_f = -Gc * v_t(t-tau) - i_t(t-tau) Y_f = -Gc * v_f(t-tau) - i_f(t-tau) X_t = -Gc * v_f(t-tau) - i_f(t-tau) Y_t = -Gc * v_t(t-tau) - i_t(t-tau)
Ih_f_next = 0.5 * ((I + H) * X_f + (I - H) * Y_f) Ih_t_next = 0.5 * ((I + H) * X_t + (I - H) * Y_t)
- Parameters:
v_f_tau β Reduced delayed from-side voltages.
v_t_tau β Reduced delayed to-side voltages.
i_f_tau β Reduced delayed from-side currents.
i_t_tau β Reduced delayed to-side currents.
- Returns:
(Ih_f_next, Ih_t_next) reduced-phase symbolic expressions.
- sym_i_f_tau: List[Any] | Noneο
- sym_i_t_tau: List[Any] | Noneο
- sym_ih_f: List[Any] | Noneο
- sym_ih_t: List[Any] | Noneο
- sym_v_f_tau: List[Any] | Noneο
- sym_v_t_tau: List[Any] | Noneο
VeraGridEngine.Templates.Emt.bess_avm_emt_template moduleο
- VeraGridEngine.Templates.Emt.bess_avm_emt_template.get_battery_avm_emt_template(vf: VarFactory, name: str) EmtModelTemplate[source]ο
Build the aggregated battery block used by the Level-1 BESS template.
The block represents the storage side as a Thevenin battery equivalent connected to the DC terminal used by the existing pseudo-EMT VSC block. It intentionally does not include a DC-link capacitor because the imported VSC block already owns the internal DC-link state
v_dcand its capacitanceC_dc. Duplicating that capacitor here would create two competing DC energy buffers.Electrical modelο
The battery is represented by a smooth open-circuit voltage and a terminal resistance:
v_oc = v_min + (v_max - v_min) * soc_limited v_bus = v_oc - r_bat * i_bat
where
i_batis taken as positive when the BESS discharges and delivers active power to the converter DC side. The DC terminal voltagev_busis passed to the imported VSC block as itsv_dc_businput.Energy modelο
The state of charge is updated from the battery terminal power. Positive power discharges the battery, while negative power charges it. Separate charge and discharge efficiencies are used through a smooth power split.
Scopeο
This is a Level-1 network EMT approximation. It includes SoC, aggregated open-circuit voltage, internal resistance and efficiency. It does not include cell electrochemistry, balancing, thermal behaviour, degradation, a detailed BMS, or a bidirectional DC-DC converter. A future Level-2 model can replace this block by an averaged DC-DC stage while keeping the imported VSC/control blocks unchanged.
- param vf:
EMT symbolic variable factory.
- param name:
Symbolic model name.
- return:
Battery-side EMT template.
- VeraGridEngine.Templates.Emt.bess_avm_emt_template.get_bess_avm_grid_following_emt_template(vf: VarFactory, name: str = 'bess_avm_grid_following_emt') EmtModelTemplate[source]ο
Build a Level-1 averaged-value grid-following BESS EMT template.
This template assembles an aggregated Battery Energy Storage System by reusing the existing pseudo-EMT converter blocks from
converter_emt_template.pyand adding only the BESS-specific storage block. The goal is to avoid duplicating PLL, VSC, outer-loop, inner-loop and dq0/abc interface logic that already exists in the standard VeraGrid converter template.Physical structureο
The assembled model is:
battery Thevenin equivalent + SoC -> VSC DC terminal -> imported VSC/DC-link block -> imported SRF-PLL -> imported outer Vdc/Q or P/Q loop -> imported inner dq0 current controller -> imported AC-side L/R dq0 interface -> abc current injection into the EMT network
The battery block provides the DC terminal voltage consumed by the imported VSC block. The imported VSC block still owns the internal DC-link capacitor and converter power/loss equations. This avoids having two DC-link capacitors in the same BESS model.
Included behaviourο
Aggregated SoC state.
SoC-dependent open-circuit voltage.
Battery internal resistance.
Charge/discharge efficiencies.
Existing averaged VSC power balance and DC-link dynamics.
Existing PLL, dq0 current control, current limiting and modulation limit.
Existing dq0-to-abc network current injection.
Not includedο
Switching-level PWM or semiconductor devices.
Cell-level electrochemistry, thermal behaviour or degradation.
Detailed BMS and cell balancing.
Bidirectional DC-DC converter stage.
Additional plant-level PPC logic beyond the imported converter controls.
Sign conventionο
Positive AC active power follows the existing pseudo-EMT converter convention. Positive battery power means the battery discharges into the converter DC side and SoC decreases.
- param vf:
EMT symbolic variable factory.
- param name:
Symbolic model name.
- return:
Fully assembled EMT BESS template.
VeraGridEngine.Templates.Emt.bridge_2level_3ph_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.bridge_2level_3ph_emt_multilinear_template.get_bridge_2level_3ph_emt_multilinear_template(vf: VarFactory, name: str = 'bridge_2level_3ph_emt_ml') EmtModelTemplate[source]ο
Build one switched 2-level bridge EMT template with explicit trig states.
This is a first-step multilinear bridge variant for the switched-converter path: - keeps the procedural PWM logic unchanged, - keeps the electrical equations/layout unchanged, - replaces direct trig usage around
theta_pllwith explicit dynamicu_cos/u_sinstates and +/-120 identities.
VeraGridEngine.Templates.Emt.bridge_2level_3ph_emt_template moduleο
- VeraGridEngine.Templates.Emt.bridge_2level_3ph_emt_template.get_bridge_2level_3ph_emt_template(vf: VarFactory, name: str = 'bridge_2level_3ph_emt') EmtModelTemplate[source]ο
Build one standalone ideal 2-level three-phase bridge EMT template.
The bridge is driven by dq0 voltage references and uses a regular-sampled three-phase PWM logic implemented in the procedural layer. The symbolic DAE only sees the held gate states and the resulting converter phase voltages.
The DC side is represented by one positive rail and one internal negative rail derived from the external DC-link voltage. This keeps the bridge standalone and directly testable before integrating it inside a full converter template.
- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Standalone EMT bridge template.
VeraGridEngine.Templates.Emt.bridge_filter_2level_3ph_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.bridge_filter_2level_3ph_emt_multilinear_template.get_bridge_filter_2level_3ph_emt_multilinear_template(vf: VarFactory, name: str = 'bridge_filter_2level_3ph_emt_ml') EmtModelTemplate[source]ο
Build a standalone 2-level bridge with a three-phase RL AC filter.
The bridge itself is the validated standalone block with procedural PWM. On top of that, this template adds one per-phase RL filter so we can validate the electrical interaction between switched converter voltages and an AC-side network before reintegrating everything into a full VSC template.
- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Standalone bridge + filter EMT template.
VeraGridEngine.Templates.Emt.bridge_filter_2level_3ph_emt_template moduleο
- VeraGridEngine.Templates.Emt.bridge_filter_2level_3ph_emt_template.get_bridge_filter_2level_3ph_emt_template(vf: VarFactory, name: str = 'bridge_filter_2level_3ph_emt') EmtModelTemplate[source]ο
Build a standalone 2-level bridge with a three-phase RL AC filter.
The bridge itself is the validated standalone block with procedural PWM. On top of that, this template adds one per-phase RL filter so we can validate the electrical interaction between switched converter voltages and an AC-side network before reintegrating everything into a full VSC template.
- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Standalone bridge + filter EMT template.
VeraGridEngine.Templates.Emt.bridge_filter_control_2level_3ph_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.bridge_filter_control_2level_3ph_emt_multilinear_template.get_bridge_filter_control_2level_3ph_emt_multilinear_template(vf: VarFactory, name: str = 'bridge_filter_control_2level_3ph_emt_ml') EmtModelTemplate[source]ο
Build one standalone bridge + filter + control EMT template.
The template reuses the validated standalone bridge + filter plant and adds one PLL plus one dq0 current controller. This is the next incremental step before reintegrating the switched plant into the full VSC model.
- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Standalone bridge + filter + control EMT template.
VeraGridEngine.Templates.Emt.bridge_filter_control_2level_3ph_emt_template moduleο
- VeraGridEngine.Templates.Emt.bridge_filter_control_2level_3ph_emt_template.get_bridge_filter_control_2level_3ph_emt_template(vf: VarFactory, name: str = 'bridge_filter_control_2level_3ph_emt') EmtModelTemplate[source]ο
Build one standalone bridge + filter + control EMT template.
The template reuses the validated standalone bridge + filter plant and adds one PLL plus one dq0 current controller. This is the next incremental step before reintegrating the switched plant into the full VSC model.
- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Standalone bridge + filter + control EMT template.
VeraGridEngine.Templates.Emt.converter_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.converter_emt_multilinear_template.get_emt_ideal_converter_multilinear(vf: VarFactory, name: str = 'ideal_converter_emt_ml') EmtModelTemplate[source]ο
Build one averaged EMT converter model using trig-transform states.
This variant keeps the exact averaged converter equations from
get_emt_ideal_converterand only replaces directsin(theta)andcos(theta)occurrences withsymbolic_ml.trig_transformvariables.
VeraGridEngine.Templates.Emt.converter_emt_template moduleο
- VeraGridEngine.Templates.Emt.converter_emt_template.get_emt_ideal_converter(vf: VarFactory, name: str = 'ideal_converter_emt') EmtModelTemplate[source]ο
Build an idealized averaged EMT converter model current injection type with DC power balance.
It does not represent: switching, PLL, inner current loop, L filter, DC capacitor, Current or voltage dependent losses Transformer Snubbers or filters
The AC-side current reference is synthesized from fundamental-frequency P/Q commands in a synchronized rotating frame. This is a better physical approximation of a grid-following converter than an instantaneous constant-power current source.
P_ref,Q_refandP_lossare interpreted in system-base units (MW / MVAr onsbase), because that is the convention used by the EMT initialization layer when it maps power-flow values into external references.- Parameters:
vf β Variable factory for creating symbolic variables
name β Name for the converter model :return: EmtModelTemplate with the converter block
- VeraGridEngine.Templates.Emt.converter_emt_template.get_full_pseudo_emt_converter(vf: VarFactory, name: str = 'pseudo_converter_emt') EmtModelTemplate[source]ο
Assemble the pseudo-EMT converter from meaningful electrical and control sub-blocks.
VeraGridEngine.Templates.Emt.converter_switched_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.converter_switched_emt_multilinear_template.get_switched_emt_converter_multilinear(vf: VarFactory, name: str = 'switched_converter_emt_ml') EmtModelTemplate[source]ο
Build switched converter with ML bridge/filter/control chain, without modifying base template files.
VeraGridEngine.Templates.Emt.converter_switched_emt_template moduleο
- VeraGridEngine.Templates.Emt.converter_switched_emt_template.get_switched_emt_converter(vf: VarFactory, name: str = 'switched_converter_emt') EmtModelTemplate[source]ο
Assemble a hybrid switched EMT converter with the same external interface as the averaged converter.
The switched converter is rebuilt incrementally around the validated
bridge + filter + controlplant. The startup remains averaged until the exactt_enable_swhandover time, and from that point on the bridge/filter plant is seen electrically by the rest of the converter.- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
Switched EMT converter template.
VeraGridEngine.Templates.Emt.dc_line_emt_template moduleο
- VeraGridEngine.Templates.Emt.dc_line_emt_template.get_dc_line_emt_template(vf: VarFactory, name: str = 'dc_line_emt_template') EmtModelTemplate[source]ο
Build a DC EMT line with the same symbolic structure as the AC PI line template.
The static DC line data currently exposes only the series resistance. To keep the EMT implementation aligned with the existing AC PI code structure without adding new static parameters, the template models:
one series current state,
one explicit shunt leg per terminal,
one tiny fixed electrical time constant that regularizes the series branch and makes it behave like a near-resistive PI section.
With zero shunt capacitance the EMT steady state remains consistent with the static PF model, while the code layout stays close to
pi_line_emt_template.- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
EMT DC line template.
- VeraGridEngine.Templates.Emt.dc_line_emt_template.get_dc_line_with_power_input_emt_template(vf: VarFactory, name: str = 'dc_line_power_input_emt') EmtModelTemplate[source]ο
Build a two-terminal DC EMT line with one external active-power order
Pext.The topology is a PI-type corridor arranged strictly in series as:
from_node -> shunt_from -> R3L3 -> v1 -> shunt_1 -> R2L2 -> v2 -> shunt_2 -> R1L1 -> shunt_to -> to_node.The model therefore contains: - four shunt capacitors: one at
from, one atv1, one atv2, and one atto, - three RL branches connected in series:R3L3,R2L2, thenR1L1, - one injected current atv1and one injected current atv2derived fromPextusing the local node voltage.
Pextis a runtime/event parameter. The template converts that power order into the local injected currentsi_n1 = Pext / v1andi_n2 = Pext / v2.Important implementation detail: -
state_vars,state_eqsanddiff_varsare kept in exactly the same order. -algebraic_varsandalgebraic_eqsare also kept in exactly the same order.- Parameters:
vf β Shared EMT variable factory.
name β Symbolic model name.
- Returns:
EMT template for the DC corridor with eventable
Pext.
VeraGridEngine.Templates.Emt.dc_load_emt_template moduleο
- VeraGridEngine.Templates.Emt.dc_load_emt_template.get_dc_load_emt_template(vf: VarFactory, name: str = 'dc_load_emt_template') EmtModelTemplate[source]ο
Build an EMT DC load model.
Static parameters are provided through
api_obj_mappingusing the associated load device.- Args:
vf: Variable factory name: Name for the model
- Returns:
EmtModelTemplate with the DC load block
VeraGridEngine.Templates.Emt.dc_source_emt_template moduleο
- class VeraGridEngine.Templates.Emt.dc_source_emt_template.ControlledDcCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.dc_source_emt_template.ControlledDcVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.dc_source_emt_template.DcCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.dc_source_emt_template.DcVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.dc_source_emt_template.get_controlled_dc_current_source_emt_template(vf: VarFactory, name: str = 'controlled_dc_current_source_emt') EmtModelTemplate[source]ο
Build one EMT DC current source driven by one command input.
The command input is the injected DC current.
- Parameters:
vf β EMT variable factory.
name β Symbolic model name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.dc_source_emt_template.get_controlled_dc_voltage_source_emt_template(vf: VarFactory, source_conductance_value: float = 100.0, name: str = 'controlled_dc_voltage_source_emt') EmtModelTemplate[source]ο
Build one EMT DC voltage source driven by one command input.
The command input is the internal source DC voltage used by the Norton equivalent
i = g * (Vcmd - Vdc).- Parameters:
vf β EMT variable factory.
source_conductance_value β Norton conductance.
name β Symbolic model name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.dc_source_emt_template.get_dc_current_source_emt_template(vf: VarFactory, source_current_value: float = 0.0, name: str = 'dc_current_source_emt') EmtModelTemplate[source]ο
Build one EMT DC current source with fixed injected current.
Positive DC current injects into the connected DC bus.
- Parameters:
vf β EMT variable factory.
source_current_value β Fixed injected DC current.
name β Symbolic model name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.dc_source_emt_template.get_dc_voltage_source_emt_template(vf: VarFactory, source_voltage_value: float | None = 0.0, source_conductance_value: float = 100.0, name: str = 'dc_voltage_source_emt') EmtModelTemplate[source]ο
Build one EMT DC voltage source using one Norton equivalent.
The source injects
i = g * (Vsrc - Vdc).- Parameters:
vf β EMT variable factory.
source_voltage_value β Fixed source voltage.
source_conductance_value β Norton conductance.
name β Symbolic model name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.emt_gfm_park_model moduleο
- VeraGridEngine.Templates.Emt.emt_gfm_park_model.build_vsc_gfm_emt_park(vfactory, name: str = 'gfm_emt')[source]ο
VeraGridEngine.Templates.Emt.generator_emt_type_template moduleο
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_complete_generator_template_emt(vf: VarFactory, name='complete_generator_emt_template') EmtModelTemplate[source]ο
- Returns:
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_exciter_emt(vf: VarFactory, name: str = 'exciter') EmtModelTemplate[source]ο
- Parameters:
vf
name
- Returns:
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_generator_emt_type_template(vf: VarFactory, name: str = 'emt_type_generator_template') EmtModelTemplate[source]ο
9-winding Synchronous Machine EMT model. The synchronous machine used by EMTP with 1 mass. Sign Convention: Generator (i_A, i_B, i_C are positive when injecting power into the grid). Park Transform: Amplitude invariant (2/3 factor), d-axis leads q-axis (d=sin, q=cos).
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_generator_sauer_pai_type_emt_template(vf: VarFactory, name: str = 'sauer_pai_generator_emt_template') EmtModelTemplate[source]ο
Sauer-Pai synchronous generator model embedded in the EMT architecture, including explicit zero-sequence dynamics.
Referencesο
- Federico Milano, Power System Modelling and Scripting:
Section 15.1.3 Common Equations
Section 15.1.4 Stator Electrical Equations
Section 15.1.5 Magnetic Equations, Sauer-Pai model (15.13)-(15.15)
Model structureο
- Electromagnetic states:
psi_d, psi_q, psi_0, e_qp, e_dp, psi_pp_d, psi_pp_q
- Mechanical / kinematic states:
theta_abs, delta_rel, omega
Inputsο
- v_A, v_B, v_C:
instantaneous abc terminal voltages
- Tm:
mechanical torque input from governor
- v_f:
field voltage input from exciter
Sign conventionο
abc stator currents i_A, i_B, i_C are positive when LEAVING the generator and entering the network.
internal magnetic/electrical equations are written in Milanoβs physical d-q axes.
zero sequence is retained explicitly and represented as a stator-only homopolar branch:
psi_0 + x0 * i_0 = 0
Anglesο
- theta_abs:
absolute electrical angle for abc <-> dq0 transforms
- delta_rel:
rotor angle relative to the synchronous reference, used in Milanoβs common electromechanical equations
Park transform convention used hereο
Physical dq0 quantities are defined from abc voltages/currents as:
v_d = -(2/3) * Ξ£ cos(theta_abs + shift_k) * v_k v_q = (2/3) * Ξ£ sin(theta_abs + shift_k) * v_k v_0 = (1/3) * (v_A + v_B + v_C)
i_d = -(2/3) * Ξ£ cos(theta_abs + shift_k) * i_k i_q = (2/3) * Ξ£ sin(theta_abs + shift_k) * i_k i_0 = (1/3) * (i_A + i_B + i_C)
and the inverse transform is:
i_A = i_q*sin(theta_abs) - i_d*cos(theta_abs) + i_0 i_B = i_q*sin(theta_abs - 2Ο/3) - i_d*cos(theta_abs - 2Ο/3) + i_0 i_C = i_q*sin(theta_abs + 2Ο/3) - i_d*cos(theta_abs + 2Ο/3) + i_0
Implemented equationsο
- Common equations:
d(theta_abs)/dt = omega_b * omega d(delta_rel)/dt = omega_b * (omega - omega_s) d(omega)/dt = (Tm - T_e - D*(omega - omega_s)) / (2H)
T_e = psi_d*i_q - psi_q*i_d
- Stator electrical equations:
d(psi_d)/dt = omega_b * (ra*i_d + omega*psi_q + v_d) d(psi_q)/dt = omega_b * (ra*i_q - omega*psi_d + v_q) d(psi_0)/dt = omega_b * (ra*i_0 + v_0)
- Sauer-Pai magnetic equations:
- d(e_qp)/dt =
(-e_qp - (xd - xdp)*(gamma_d1*i_d - gamma_d2*psi_pp_d + gamma_d2*e_qp) + v_f) / Td0p
- d(e_dp)/dt =
(-e_dp + (xq - xqp)*(gamma_q1*i_q - gamma_q2*psi_pp_q - gamma_q2*e_dp)) / Tq0p
d(psi_pp_d)/dt = (-psi_pp_d + e_qp - (xdp - xl)*i_d) / Td0pp d(psi_pp_q)/dt = (-psi_pp_q - e_dp - (xqp - xl)*i_q) / Tq0pp
- Algebraic magnetic equations:
0 = psi_d + xdpp*i_d - gamma_d1*e_qp - (1 - gamma_d1)*psi_pp_d 0 = psi_q + xqpp*i_q + gamma_q1*e_dp - (1 - gamma_q1)*psi_pp_q 0 = psi_0 + x0*i_0
- Terminal powers (abc domain):
p_e = v_A*i_A + v_B*i_B + v_C*i_C q_e = 1/sqrt(3) * [(v_A-v_B)i_C + (v_B-v_C)i_A + (v_C-v_A)i_B]
Assumptionsο
Balanced rotor / Park-model machine.
Zero sequence is NOT neglected.
Zero-sequence path has no rotor coupling and is represented by x0 only.
Tm and v_f are external controller inputs and are initialized at equilibrium.
Initialization is pragmatic and closed-form, not a full nonlinear equilibrium solve.
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_governor_emt(vf: VarFactory, name: str = 'Governor') EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_pf_positive_sequence_init_refs(v_a: Expr, v_b: Expr, v_c: Expr, d_v_a: Expr, d_v_b: Expr, d_v_c: Expr, p_a: Expr, q_a: Expr, p_b: Expr, q_b: Expr, p_c: Expr, q_c: Expr, omega_base: Expr) tuple[Expr, Expr, Expr, Expr][source]ο
Compute generator initialization references from PF voltage and power inputs.
- Parameters:
v_a β Instantaneous phase-A voltage at
t = 0.v_b β Instantaneous phase-B voltage at
t = 0.v_c β Instantaneous phase-C voltage at
t = 0.d_v_a β Instantaneous derivative of phase-A voltage at
t = 0.d_v_b β Instantaneous derivative of phase-B voltage at
t = 0.d_v_c β Instantaneous derivative of phase-C voltage at
t = 0.p_a β Active power in phase A.
q_a β Reactive power in phase A.
p_b β Active power in phase B.
q_b β Reactive power in phase B.
p_c β Active power in phase C.
q_c β Reactive power in phase C.
omega_base β Electrical base angular frequency.
- Returns:
Tuple
(phi_v, phi, vpk, ipk).
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_simple_generator_emt_template(vf: VarFactory, name: str = 'simple_emt_type_generator_template') EmtModelTemplate[source]ο
EMT type machine model without damping effects. :param vf: grid.var_factory :param name: string to identify the generator and model :return: EmtModelTemplate
- VeraGridEngine.Templates.Emt.generator_emt_type_template.get_stabilizer_emt(vf: VarFactory, name: str = 'stabilizer') EmtModelTemplate[source]ο
VeraGridEngine.Templates.Emt.induction_motor_emt_template moduleο
EMT induction-motor templates.
This module provides three EMT induction-motor builders that share the same external ABC bus interface and the same load-oriented power-flow parameter mappings. The recommended implementation is the Level-2 single-cage EMT model.
Model overviewο
The templates represent an induction motor as a three-phase EMT load connected
to instantaneous ABC terminal voltages. Internally, the electrical equations are
written in stationary alpha-beta coordinates through the amplitude-invariant
Clarke transform. Flux linkages are the dynamic electrical states, stator and
rotor currents are algebraic variables obtained from the inductance relations,
and the normalized rotor speed is the mechanical state.
The Level-2 model is a single-cage induction motor. It includes two stator flux equations, two rotor flux equations, one rotor-speed swing equation, the current-flux algebraic constraints, active/reactive power equations, electromagnetic torque, mechanical load torque and slip. The mechanical load is modelled as a quadratic speed-dependent torque, which is a common default for fan- and pump-like motor loads. The sign convention at the EMT bus is load oriented: the internal motor current absorbs power, while the exported ABC current variables are the currents injected into the network, hence the opposite sign in the ABC current equations.
The Level-3 model keeps the same external ABC interface but replaces the single rotor cage with two parallel rotor cages sharing the same magnetizing branch. This increases the fidelity of the rotor transient response while preserving the same torque, slip, power and terminal-current conventions.
Initialization reconstructs peak phasors from the instantaneous terminal voltages and their derivatives, converts the power-flow P/Q targets into phase current phasors, extracts a positive-sequence equivalent operating point, estimates a physically bounded slip and then seeds currents, fluxes, speed, powers, electromagnetic torque and the nominal mechanical-load coefficient.
- class VeraGridEngine.Templates.Emt.induction_motor_emt_template.InductionMotorEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.induction_motor_emt_template.get_induction_motor_double_cage_emt_template(vf: VarFactory, name: str = 'induction_motor_double_cage_emt_template') EmtModelTemplate[source]ο
Build the Level-3 EMT double-cage induction-motor template.
This model keeps the same ABC EMT terminal interface as the Level-2 block, but it splits the rotor current into two parallel cages that share one common magnetizing branch. The resulting model is better suited to capture high inrush current and deep-bar behaviour during startup.
The initialization is intentionally conservative: it uses the power-flow target to seed the stator current and then distributes the rotor current between cages according to their impedances at the estimated slip.
- Parameters:
vf β EMT variable factory.
name β Symbolic template name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.induction_motor_emt_template.get_induction_motor_emt_template(vf: VarFactory, level: int = 2, name: str = 'induction_motor_emt_template') EmtModelTemplate[source]ο
Build one induction-motor EMT template for the requested fidelity level.
Level selection:
2: Recommended EMT single-cage model.3: EMT double-cage model.
- Parameters:
vf β EMT variable factory.
level β Requested model level.
name β Symbolic template name.
- Returns:
Configured EMT template.
- Raises:
ValueError β If the requested level is not supported.
- VeraGridEngine.Templates.Emt.induction_motor_emt_template.get_induction_motor_single_cage_emt_template(vf: VarFactory, name: str = 'induction_motor_emt_template') EmtModelTemplate[source]ο
Build the recommended Level-2 EMT single-cage induction-motor template.
The model uses a stationary
alpha-betaformulation internally so it can connect directly to the existing EMT ABC bus architecture while still keeping explicit stator and rotor electrical dynamics.Mechanical torque follows a quadratic speed law, which is a practical default for fan- and pump-like motor loads. The nominal torque coefficient is seeded from the electrical initial condition so the machine starts from a consistent operating point when power-flow data is available.
- Parameters:
vf β EMT variable factory.
name β Symbolic template name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.jmarti_line_emt_template moduleο
- class VeraGridEngine.Templates.Emt.jmarti_line_emt_template.JmartiLineEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.jmarti_line_emt_template.get_jmarti_line_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, name: str | None = 'J_Marti') EmtModelTemplate[source]ο
Create the symbolic EMT template shell for a JMARTI line.
The active JMARTI runtime computes the effective Norton injections and writes them into retained history parameters, exactly like the Bergeron workflow. The symbolic template therefore only exposes terminal voltages and the phase-domain history current parameters used by the runtime companion.
- Parameters:
vf β EMT variable factory.
phN β True if the line has neutral, else False.
phA β True if phase A is active, else False.
phB β True if phase B is active, else False.
phC β True if phase C is active, else False.
name β Symbolic model name.
- Returns:
EMT JMARTI line template.
VeraGridEngine.Templates.Emt.load_RLC_emt_template moduleο
Phase-selective EMT templates for shunt R/L/C devices.
- class VeraGridEngine.Templates.Emt.load_RLC_emt_template.GroundingLinkEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.load_RLC_emt_template.ShuntRlcComboEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_ground_emt_template(vf: VarFactory, name: str = 'ground_emt') EmtModelTemplate[source]ο
Build one ideal EMT ground block for an internal neutral node.
The block clamps its input node voltage to zero and exposes the corresponding grounding current as one output so a parent template can close the neutral KCL.
- Parameters:
vf β EMT variable factory.
name β Symbolic model name.
- Returns:
Ideal ground EMT template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_grounding_link_emt_template(vf: VarFactory, include_r: bool, include_l: bool, include_c: bool, solid_connection: bool = False, nested: bool = False, direct_r_value: float | None = None, direct_l_value: float | None = None, direct_c_value: float | None = None, name: str = 'grounding_link_emt') EmtModelTemplate[source]ο
Build one configurable one-terminal EMT grounding-link block.
The block exposes one node-voltage input and one injected-current output, while grounding the opposite terminal internally through
Ground EMT.- Parameters:
vf β EMT variable factory.
include_r β Include the resistor branch.
include_l β Include the inductor branch.
include_c β Include the capacitor branch.
direct_r_value β Optional direct resistor value in ohms.
direct_l_value β Optional direct inductance value in henries.
direct_c_value β Optional direct capacitance value in farads.
name β Symbolic model name.
- Returns:
Grounding-link EMT template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_shunt_c_emt_template(vf: VarFactory, phA: bool, phB: bool, phC: bool, name: str = 'C_shunt') EmtModelTemplate[source]ο
Build a phase-selective shunt capacitor EMT template.
- Parameters:
vf β EMT variable factory.
phA β True when phase A is active.
phB β True when phase B is active.
phC β True when phase C is active.
name β Optional symbolic model name.
- Returns:
Configured capacitor EMT template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_shunt_l_emt_template(vf: VarFactory, phA: bool, phB: bool, phC: bool, name: str = 'L_shunt') EmtModelTemplate[source]ο
Build a phase-selective shunt inductor EMT template.
- Parameters:
vf β EMT variable factory.
phA β True when phase A is active.
phB β True when phase B is active.
phC β True when phase C is active.
name β Optional symbolic model name.
- Returns:
Configured inductor EMT template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_shunt_r_emt_template(vf: VarFactory, phA: bool = True, phB: bool = True, phC: bool = True, name: str = 'R_shunt') EmtModelTemplate[source]ο
Build a phase-selective shunt resistor EMT template.
- Parameters:
vf β EMT variable factory.
phA β Bool. True if the load has phase A, else False.
phB β Bool. True if the load has phase B, else False.
phC β Bool. True if the load has phase C, else False.
name β Optional symbolic model name.
- Returns:
EMT shunt resistor template sized to the active phases.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.get_shunt_rlc_combo_emt_template(vf: VarFactory, include_r: bool, include_l: bool, include_c: bool, phA: bool = True, phB: bool = True, phC: bool = True, connection_type: ShuntConnectionType = Yg, direct_r_value: float | None = None, direct_l_value: float | None = None, direct_c_value: float | None = None, name: str = 'RLC_combo_emt') EmtModelTemplate[source]ο
Build one star-connected combined EMT shunt with explicit neutral handling.
FloatingStarkeeps an internal floating neutral node,NeutralStarexposes one external neutral port, andGroundedStarinstantiates one internal ideal-ground subblock connected to the same neutral node.- Parameters:
vf β EMT variable factory.
include_r β Include the resistor branch.
include_l β Include the inductor branch.
include_c β Include the capacitor branch.
phA β Enable phase A.
phB β Enable phase B.
phC β Enable phase C.
connection_type β Requested star connection type.
name β Symbolic model name.
- Returns:
Combined EMT shunt template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.wrap_delta_referenced_load_emt_template(vf: VarFactory, core_template: EmtModelTemplate, active_phases: List[str], name: str) EmtModelTemplate[source]ο
Wrap one phase-selective EMT load template with explicit delta topology.
The child template is interpreted as branch-based with the mapping
A -> AB,B -> BCandC -> CA.- Parameters:
vf β EMT variable factory.
core_template β Existing phase-selective child template built for delta branches.
active_phases β Active bus-phase labels.
name β Symbolic wrapper name.
- Returns:
Wrapped delta EMT template.
- VeraGridEngine.Templates.Emt.load_RLC_emt_template.wrap_ground_referenced_load_emt_template(vf: VarFactory, core_template: EmtModelTemplate, active_phases: List[str], connection_type: ShuntConnectionType, name: str) EmtModelTemplate[source]ο
Wrap one phase-selective EMT load template with explicit neutral/ground topology.
The wrapped child keeps its original electrical equations and API mappings, while the outer block adds one neutral node, optional auto-grounding link, and per-phase phase-to-neutral voltage drops.
- Parameters:
vf β EMT variable factory.
core_template β Existing phase-selective child template.
active_phases β Ordered active phase labels.
connection_type β
FloatingStar,NeutralStarorGroundedStar.name β Symbolic wrapper name.
- Returns:
Wrapped EMT template.
VeraGridEngine.Templates.Emt.load_exponential_emt_template moduleο
Phase-selective EMT exponential-load template.
- class VeraGridEngine.Templates.Emt.load_exponential_emt_template.ExponentialLoadEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.load_exponential_emt_template.get_exponential_load_emt(vf: VarFactory, phA: bool = True, phB: bool = True, phC: bool = True, connection_type: ShuntConnectionType | None = None, name: str = 'EXP_Load_EMT_3ph') EmtModelTemplate[source]ο
Build the phase-selective EMT exponential-load template.
The load keeps the original per-phase SOGI state model and exponential voltage dependence, but instantiates those equations only for the phases enabled by
phA,phBandphC.- Parameters:
vf β EMT variable factory.
phA β True when phase A is active.
phB β True when phase B is active.
phC β True when phase C is active.
connection_type β Optional explicit star connection topology.
name β Symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.load_zip_emt_template moduleο
Phase-selective EMT ZIP-load template.
- class VeraGridEngine.Templates.Emt.load_zip_emt_template.LoadZIPEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.load_zip_emt_template.LoadZipEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.load_zip_emt_template.get_load_ZIP_emt_template(vf: VarFactory, phA: bool = True, phB: bool = True, phC: bool = True, connection_type: ShuntConnectionType | None = None, name: str = 'ZIP_Load_EMT_3ph') EmtModelTemplate[source]ο
Build the phase-selective EMT ZIP-load template.
The original per-phase SOGI filter and ZIP polynomial are reused without changing their formulas. Only the number and ordering of the generated phase blocks now follow the explicit
phA/phB/phCselection.- Parameters:
vf β EMT variable factory.
phA β True when phase A is active.
phB β True when phase B is active.
phC β True when phase C is active.
connection_type β Optional explicit star connection topology.
name β Symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.nonlinear_resistor_emt_template moduleο
- VeraGridEngine.Templates.Emt.nonlinear_resistor_emt_template.get_nonlinear_resistor_emt_template(vf: VarFactory, voltage_points: Sequence[float], current_points: Sequence[float], name: str = 'nonlinear_resistor_emt') EmtModelTemplate[source]ο
Build one ATP-like one-terminal nonlinear resistor EMT block.
The block uses an odd-symmetric piecewise-linear |v| -> |i| curve and grounds the opposite terminal internally.
- Parameters:
vf β EMT variable factory.
voltage_points β Non-negative voltage magnitudes.
current_points β Matching current magnitudes.
name β Symbolic block name.
- Returns:
Materialized EMT template.
VeraGridEngine.Templates.Emt.pi_line_emt_template moduleο
- class VeraGridEngine.Templates.Emt.pi_line_emt_template.PiLineEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.pi_line_emt_template.get_pi_line_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, name: str = 'Pi') EmtModelTemplate[source]ο
Build the EMT pi-line template with explicit API-mapped parameters.
The line connection defines which phases are physically present, while the EMT initializer later injects the electrical
R,LinvandCvalues through the blockapi_obj_mappingusing the full 4x4 NABC enum contract.- Parameters:
vf β EMT variable factory.
phN β Bool. True if the line has neutral, else False.
phA β Bool. True if the line has phase A, else False.
phB β Bool. True if the line has phase B, else False.
phC β Bool. True if the line has phase C, else False.
name β Symbolic model name.
- Returns:
EMT pi-line model template.
- Raises:
ValueError β If the line has no active phases.
VeraGridEngine.Templates.Emt.pv_emt_template moduleο
- class VeraGridEngine.Templates.Emt.pv_emt_template.PvEmtModelLevel(value)[source]ο
Bases:
IntEnumEnumerate the supported PV EMT template detail levels.
LEVEL_1is the simplified PV availability plus MPPT-lag model, whileLEVEL_2adds the averaged PV plus DC-DC boost dynamics.- Variables:
LEVEL_1 β Simplified PV availability plus MPPT-lag model.
LEVEL_2 β Averaged PV plus DC-DC boost model.
- LEVEL_1 = 1ο
- LEVEL_2 = 2ο
- VeraGridEngine.Templates.Emt.pv_emt_template.get_pv_avm_boost_grid_following_emt_template(vf: VarFactory, name: str = 'pv_avm_boost_grid_following_emt') EmtModelTemplate[source]ο
Build the Level-2 PV averaged DC-DC plus grid-following VSC EMT template.
Structureο
The assembled model is:
PV array equivalent from irradiance and temperature -> averaged boost converter with MPPT duty-cycle dynamics -> internal DC terminal voltage -> imported VSC/DC-link block -> imported SRF-PLL -> imported outer P/Q or Vdc/Q loop -> imported inner dq0 current controller -> imported AC-side dq0/abc interface -> abc current injection into the EMT network
Compared with Level 1ο
Level 1 only computes available PV power and applies an MPPT lag. Level 2 adds explicit averaged boost-converter variables: PV MPP voltage/current, PV-side voltage, duty-cycle state, MPPT PI integrator and boost efficiency.
Not includedο
Switching-level DC-DC or PWM detail.
Semiconductor device models.
Cell-level diode equations.
Plant-level PPC beyond the imported converter control interface.
- param vf:
EMT symbolic variable factory.
- param name:
Symbolic model name.
- return:
Fully assembled Level-2 PV EMT template.
- VeraGridEngine.Templates.Emt.pv_emt_template.get_pv_avm_grid_following_emt_template(vf: VarFactory, name: str = 'pv_avm_grid_following_emt') EmtModelTemplate[source]ο
Build the Level-1 PV averaged-value grid-following EMT template.
This model is the PV counterpart of the Level-1 BESS model. It can replace the BESS template in the same AC EMT examples because the external network interface is the same: three AC phase voltages as inputs and three AC phase currents as outputs.
Structureο
The assembled model is:
PV availability from irradiance and temperature -> first-order MPPT power availability -> internal DC terminal voltage -> imported VSC/DC-link block -> imported SRF-PLL -> imported outer P/Q or Vdc/Q loop -> imported inner dq0 current controller -> imported AC-side dq0/abc interface -> abc current injection into the EMT network
Included behaviourο
Irradiance-dependent available active power.
Cell-temperature active-power correction.
MPPT first-order lag.
PV curtailment diagnostic channel.
Existing averaged VSC power balance and DC-link dynamics.
Existing PLL, dq0 current control, current limiting and modulation limit.
Not includedο
Explicit PV diode equation or cell-level model.
Explicit averaged boost converter.
Switching-level PWM or semiconductor devices.
Plant-level PPC beyond the imported converter control interface.
- param vf:
EMT symbolic variable factory.
- param name:
Symbolic model name.
- return:
Fully assembled Level-1 PV EMT template.
- VeraGridEngine.Templates.Emt.pv_emt_template.get_pv_grid_following_emt_template(vf: VarFactory, level: PvEmtModelLevel | int, name: str) EmtModelTemplate[source]ο
Build one PV EMT template from the requested model-detail level.
This helper keeps the Level-1 and Level-2 public constructors unchanged while giving scripts one typed selection point for level-aware examples.
- Parameters:
vf β EMT symbolic variable factory.
level β Requested PV model-detail level.
name β Symbolic model name.
- Returns:
Fully assembled PV EMT template for the requested level.
- Raises:
ValueError β If the requested level is not supported.
VeraGridEngine.Templates.Emt.simple_generator_emt_template moduleο
- VeraGridEngine.Templates.Emt.simple_generator_emt_template.get_simple_generator_emt_template(vf: VarFactory, name: str = 'simple_emt_type_generator_template') EmtModelTemplate[source]ο
EMT type machine model without damping effects. :param vf: grid.var_factory :param name: string to identify the generator and model :return: EmtModelTemplate
VeraGridEngine.Templates.Emt.simple_generator_emt_trig_template moduleο
- VeraGridEngine.Templates.Emt.simple_generator_emt_trig_template.get_complete_generator_template_emt_trig_transform(vf: VarFactory, name: str = 'complete_generator_emt_template_ml') EmtModelTemplate[source]ο
Backward-compatible alias for multilinear reference complete generator.
- VeraGridEngine.Templates.Emt.simple_generator_emt_trig_template.get_simple_generator_emt_template_trig_transform(vf: VarFactory, name: str = 'simple_emt_type_generator_template_ml') EmtModelTemplate[source]ο
Multilinear reformulation variant of get_simple_generator_emt_template.
This function is intentionally kept equivalent to Templates/Emt/simple_generator_emt_template.py:get_simple_generator_emt_template except for replacing direct sin/cos(theta +/- 2pi/3) calls with auxiliary u_sin/u_cos state variables and trig-identity combinations.
- VeraGridEngine.Templates.Emt.simple_generator_emt_trig_template.get_simple_multilinear_generator_reference_template(vf: VarFactory, name: str = 'complete_generator_emt_template_ml') EmtModelTemplate[source]ο
VeraGridEngine.Templates.Emt.source_emt_template moduleο
- class VeraGridEngine.Templates.Emt.source_emt_template.ControlledCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.source_emt_template.ControlledVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.source_emt_template.CurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.source_emt_template.VoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.source_emt_template.get_controlled_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, frequency_hz: float = 50.0, phase_angle_deg: Dict[str, float] | None = None, offset_values: Dict[str, float] | None = None, name: str | None = 'controlled_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective controlled sinusoidal EMT current source.
The command inputs represent the per-phase sinusoidal amplitudes.
- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
frequency_hz β Common sinusoidal frequency in Hz.
phase_angle_deg β Optional phase offsets in degrees by phase label.
offset_values β Optional DC offsets by phase label.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.source_emt_template.get_controlled_voltage_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, frequency_hz: float = 50.0, phase_angle_deg: Dict[str, float] | None = None, offset_values: Dict[str, float] | None = None, source_conductance_value: float = 0.0, name: str | None = 'controlled_voltage_source_emt') EmtModelTemplate[source]ο
Build one phase-selective controlled sinusoidal EMT voltage source.
The command inputs represent the per-phase sinusoidal amplitudes. The bus sees the same Norton-like equivalent
i = g * (v_src - v_bus).- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
frequency_hz β Common sinusoidal frequency in Hz.
phase_angle_deg β Optional phase offsets in degrees by phase label.
offset_values β Optional DC offsets by phase label.
source_conductance_value β Common Norton conductance.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.source_emt_template.get_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, amplitude_values: Dict[str, float] | None = None, frequency_hz: float = 50.0, phase_angle_deg: Dict[str, float] | None = None, offset_values: Dict[str, float] | None = None, name: str | None = 'current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective sinusoidal EMT current source.
Positive currents inject into the connected bus according to the existing EMT source convention used by generator-like blocks.
- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
amplitude_values β Optional sinusoidal amplitudes by phase label.
frequency_hz β Common sinusoidal frequency in Hz.
phase_angle_deg β Optional phase offsets in degrees by phase label.
offset_values β Optional DC offsets by phase label.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.source_emt_template.get_voltage_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = True, phC: bool = True, amplitude_values: Dict[str, float] | None = None, frequency_hz: float = 50.0, phase_angle_deg: Dict[str, float] | None = None, offset_values: Dict[str, float] | None = None, source_conductance_value: float = 0.0, name: str | None = 'voltage_source_emt') EmtModelTemplate[source]ο
Build one phase-selective sinusoidal EMT voltage source using one Norton-like injection.
The block injects
i = g * (v_src - v_bus)wherev_srcis one internally generated sinusoidal waveform.- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
amplitude_values β Optional sinusoidal amplitudes by phase label.
frequency_hz β Common sinusoidal frequency in Hz.
phase_angle_deg β Optional phase offsets in degrees by phase label.
offset_values β Optional DC offsets by phase label.
source_conductance_value β Common Norton conductance.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.switch_emt_template moduleο
- class VeraGridEngine.Templates.Emt.switch_emt_template.SwitchEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.switch_emt_template.get_switch_emt_template(vf: VarFactory, phA: bool = True, phB: bool = True, phC: bool = True, signal_controlled: bool = False, seed_from_pf_active: bool = True, initial_closed: bool = True, use_device_conductance: bool = True, manual_closed_conductance: float = 10000.0, open_conductance: float = 1e-08, switch_time_constant: float = 0.0001, command_threshold: float = 0.5, name: str = 'switch_emt_template') EmtModelTemplate[source]ο
Build one phase-selective EMT switch branch template.
- Parameters:
vf β EMT variable factory.
phA β Enable phase A.
phB β Enable phase B.
phC β Enable phase C.
signal_controlled β If True, expose one control input and procedural logic.
seed_from_pf_active β If True, seed the closed/open mode from Switch.active.
initial_closed β Default closed state when PF seeding is disabled.
use_device_conductance β If True, use the switch static R/X to derive the closed conductance.
manual_closed_conductance β Manual closed conductance fallback.
open_conductance β Open-state leakage conductance.
switch_time_constant β First-order current time constant.
command_threshold β Control threshold for the external command.
name β Symbolic model name.
- Returns:
EMT switch template.
VeraGridEngine.Templates.Emt.thevenin_equivalent_emt_generator_template moduleο
- VeraGridEngine.Templates.Emt.thevenin_equivalent_emt_generator_template.get_generator_thevenin_rl_emt_template_with_ref(vf: VarFactory, name: str = 'emt_thevenin_eq_generator_template') EmtModelTemplate[source]ο
Build the ref-capable three-phase EMT Thevenin generator.
The dynamic equations intentionally preserve the original passive Thevenin source behaviour that older EMT examples and snapshots rely on. The extra sharing references are exposed only through the symbolic mappings so
EmtProblemDaecan assign them consistently across devices without altering the local Thevenin source dynamics.Inputsο
v_A,v_B,v_C:Instantaneous bus terminal voltages in pu.
Statesο
i_A,i_B,i_C:Phase currents injected into the bus in pu.
theta:Absolute electrical angle of the internal balanced source in rad.
The optional sharing references are exposed through the mappings, but they do not introduce extra EMT states or controller dynamics inside the template itself.
Parametersο
- Static generator parameters:
omega_base,R_s,X_s- PF-derived initialization parameters:
phi_v,phi,Vpk,Ipk- Optional sharing references:
share_enable,P_share_ref,Q_share_ref- Event parameters:
phi_v,phi,Vpk,Ipk,E_scale
Initializationο
The PF initialization reconstructs the positive-sequence internal emf using:

and then initializes:
theta = phi_v + delta
so that the passive Thevenin source starts exactly from the PF operating point used by the legacy EMT examples.
- param vf:
EMT variable factory.
- param name:
Symbolic block name.
- return:
Configured EMT template.
VeraGridEngine.Templates.Emt.transformer_emt_template moduleο
- class VeraGridEngine.Templates.Emt.transformer_emt_template.TransformerEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.transformer_emt_template.get_transformer_emt_template(vf: VarFactory, conn_f: WindingType | None = None, conn_t: WindingType | None = None, name: str = 'transformer_emt_template') EmtModelTemplate[source]ο
Build a linear two-winding transformer EMT template using coupled winding currents as state variables.
This simplified version keeps only the series coupled-winding model and omits the primary shunt branch from the EMT equations. The total voltage ratio is exposed through api_obj_mapping and is used to initialize the primary winding current from the secondary-side port current in a way that is consistent with the external port convention.
Assumptions: - l1, l2, and m12 already represent the physical transformer model in the
chosen winding coordinates.
branch currents are positive when leaving the connected bus.
if_act and it_act are externally initialized by the EMT framework from the power-flow solution through external_mapping.
- Parameters:
vf β EMT variable factory.
conn_f β Optional from-side winding connection.
conn_t β Optional to-side winding connection.
name β Symbolic model name.
- Returns:
EMT transformer model template.
VeraGridEngine.Templates.Emt.transient_source_emt_template moduleο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.CigreSurgeCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.DoubleExponentialCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.HeidlerCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.RampCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.RampVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.StepCurrentSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- class VeraGridEngine.Templates.Emt.transient_source_emt_template.StepVoltageSourceEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_cigre_surge_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, a_value: float = 1000.0, b_value: float = 10000.0, n_value: float = 2.0, tn_s: float = 0.0001, i1_value: float = 1.0, t1_s: float = 0.0005, i2_value: float = 0.5, t2_s: float = 0.0002, delay_s: float = 0.0, name: str | None = 'cigre_surge_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT CIGRE surge current source.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_double_exponential_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, amplitude_value: float = 1.0, alpha_value: float = 100.0, beta_value: float = 5000.0, delay_s: float = 0.0, name: str | None = 'double_exponential_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT double-exponential current source.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_heidler_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, peak_value: float = 1.0, front_time_s: float = 0.0001, tail_time_s: float = 0.0005, order_value: float = 4.0, delay_s: float = 0.0, name: str | None = 'heidler_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT Heidler current source.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_ramp_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, initial_value: float = 0.0, final_value: float = 1.0, start_time_s: float = 0.01, end_time_s: float = 0.03, name: str | None = 'ramp_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT ramp current source.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_ramp_voltage_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, initial_value: float = 0.0, final_value: float = 1.0, start_time_s: float = 0.01, end_time_s: float = 0.03, source_conductance_value: float = 100.0, name: str | None = 'ramp_voltage_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT ramp voltage source.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_step_current_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, initial_value: float = 0.0, final_value: float = 1.0, step_time_s: float = 0.02, name: str | None = 'step_current_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT step current source.
- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
initial_value β Value before the step.
final_value β Value after the step.
step_time_s β Step time in seconds.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
- VeraGridEngine.Templates.Emt.transient_source_emt_template.get_step_voltage_source_emt_template(vf: VarFactory, phN: bool = False, phA: bool = True, phB: bool = False, phC: bool = False, initial_value: float = 0.0, final_value: float = 1.0, step_time_s: float = 0.02, source_conductance_value: float = 100.0, name: str | None = 'step_voltage_source_emt') EmtModelTemplate[source]ο
Build one phase-selective EMT step voltage source.
- Parameters:
vf β EMT variable factory.
phN β Whether neutral is active.
phA β Whether phase A is active.
phB β Whether phase B is active.
phC β Whether phase C is active.
initial_value β Value before the step.
final_value β Value after the step.
step_time_s β Step time in seconds.
source_conductance_value β Norton conductance.
name β Optional symbolic block name.
- Returns:
Configured EMT template.
VeraGridEngine.Templates.Emt.valve_emt_template moduleο
- VeraGridEngine.Templates.Emt.valve_emt_template.get_valve_emt_template(vf: VarFactory, name: str = 'valve_emt_template', valve_tpe: ValveEmtType = IGBT, model_variant: ValveEmtModelVariant = Ideal, initial_state: ValveInitializationState = Blocked, antiparallel_diode: bool = True) EmtModelTemplate[source]ο
Build a generic two-terminal EMT valve template.
The template represents one controlled DC semiconductor branch that can be reused inside arbitrary EMT models. It exposes explicit terminal voltages and currents so it can act as a standalone two-terminal DC branch or as a nested sub-block inside a larger converter model.
The retained conduction path is encoded as:
+1: forward conduction from thefromside to thetoside0: blocked state-1: reverse conduction through the antiparallel path
- Parameters:
vf β Shared symbolic variable factory.
name β Template instance name.
valve_tpe β Valve physical type.
model_variant β Valve EMT modelling variant.
initial_state β Startup policy for the conduction state.
antiparallel_diode β Enable the reverse freewheeling path.
- Returns:
Reusable EMT valve template.
VeraGridEngine.Templates.Emt.vsc_gfl_emt moduleο
- VeraGridEngine.Templates.Emt.vsc_gfl_emt.VscGflEmtBuild(vfactory: VarFactory, name: str = '', control1: ConverterControlType = P_ac, control2: ConverterControlType = Q_ac) EmtModelTemplate[source]ο
VSC GFL (Grid Following) EMT model with from side the DC bus and to side the AC bus
- Args:
name: Model name control1: First control mode (Pac, Pdc, or Vm_dc) control2: Second control mode (Qac or Vm_ac)
- Supported control combinations:
Pac + Qac: Active and reactive power control
Pac + Vm_ac: Active power and AC voltage control
Pdc + Qac: DC power and reactive power control
Pdc + Vm_ac: DC power and AC voltage control
Vm_dc + Qac: DC voltage and reactive power control
Vm_dc + Vm_ac: DC voltage and AC voltage control
- VeraGridEngine.Templates.Emt.vsc_gfl_emt.build_gfl_converter_model_emt(vfactory: VarFactory, inputs, control1: ConverterControlType = P_ac, control2: ConverterControlType = Q_ac, multilinear: bool = False)[source]ο
Build power control loop model for Grid Following Converter for EMT simulation. Supports multiple control modes via ConverterControlType.
- Args:
- inputs: [vc_A, vc_B, vc_C, vg_A, vg_B, vg_C, i_A, i_B, i_C, Vdc,
Pt_vsc, Qt_vsc, Vpk_ref, phi_v_ref]
control1: First control mode (typically active power or DC voltage related) control2: Second control mode (typically reactive power or AC voltage related) multilinear: Use multilinearization for Park transforms
- Returns:
gfl_block: The complete converter block i_a_inj, i_b_inj, i_c_inj: Three-phase bus injection currents P, Q: Active and reactive power measurements
- VeraGridEngine.Templates.Emt.vsc_gfl_emt.inverse_park_transform_block(vfactory: VarFactory, v_dq: list[Var], theta: Var, aux_vars=None, multilinear: bool = False, name: str = '')[source]ο
Create a symbolic inverse Park transform (dq β abc) block for voltages.
v_dq = [v_d_c, v_q_c] theta : grid angle (from PLL) multilinear : if True, use u_cos/u_sin auxiliary variables (for multilinearization)
- VeraGridEngine.Templates.Emt.vsc_gfl_emt.park_transform_block(vfactory: VarFactory, v_abc: list[Var], theta: Var, multilinear: bool = False, aux_vars=None, name: str = '')[source]ο
Create a symbolic Park transform (abc β dq) block for voltages and currents.
i_abc = [i_a, i_b, i_c] v_abc = [v_a, v_b, v_c] theta : grid angle (from PLL)
- VeraGridEngine.Templates.Emt.vsc_gfl_emt.pll_transform(vfactory: VarFactory, v_abc, multilinear: bool = False, name: str = '')[source]ο
EMT PLL using instantaneous three-phase voltages.
VeraGridEngine.Templates.Emt.xfmr_emt_multilinear_template moduleο
- VeraGridEngine.Templates.Emt.xfmr_emt_multilinear_template.get_xfmr_emt_template_multilinear(vf: VarFactory, name: str = 'xfmr_emt_template_ml') EmtModelTemplate[source]ο
Build the EMT DAE template of a basic ATP-like transformer model.
Multilinear variant notesο
This function mirrors
get_xfmr_emt_templatestructure/order/comments and keeps the same physics. The only intended reformulation is:squared terms are represented with auxiliary variables, and
nonlinear constitutive equations are written in multiplied form.
VeraGridEngine.Templates.Emt.xfmr_emt_template moduleο
- class VeraGridEngine.Templates.Emt.xfmr_emt_template.XfmrEmtTemplate(vf)[source]ο
Bases:
TemplateDefinition- eval() EmtModelTemplate[source]ο
- VeraGridEngine.Templates.Emt.xfmr_emt_template.get_xfmr_emt_template(vf: VarFactory, conn_f: WindingType | None = None, conn_t: WindingType | None = None, name: str = 'xfmr_emt_template') EmtModelTemplate[source]ο
Build the EMT DAE template of a basic ATP-like transformer model.
Overviewο
This transformer model is organized as:
one series leakage branch between the two transformer terminals,
one magnetizing/core branch referred to the from side only,
one linear core-loss branch referred to the from side only,
optional terminal shunt capacitances represented through charge states.
The model is intentionally kept close to the classical robust transformer equivalent used in EMT-type formulations:
the leakage path couples the from and to terminals,
the core is excited from the from-side winding voltage only,
the core current is injected only on the from side.
This avoids the algebraic/numerical issues caused by splitting the magnetic branch symmetrically between both sides.
Parameter ownershipο
This template follows the requested VeraGrid architecture:
api_obj_mapping: only parameters that come from the static transformer object or are passed almost directly by the EMT assembler.
event_dict: parameters of the dynamic transformer model that are not explicit static data and can be overridden through set_parameter_in_model().
init_eqs: initialization equations of internal algebraic and state variables.
diff_init_eqs: initialization equations of internal derivatives.
Static mapped parametersο
Expected from the EMT assembler through api_obj_mapping:
omega_base
transformer_rated_power_mva
transformer_open_circuit_current_pct
transformer_open_circuit_loss_kw
transformer_short_circuit_voltage_pct
transformer_short_circuit_loss_kw
tap_module
transformer_from_connection_**
transformer_to_connection_**
Dynamic local parametersο
Local model parameters stored in event_dict:
xfmr_core_topology_code
xfmr_yoke_area_rel
xfmr_yoke_length_rel
xfmr_outer_leg_area_rel
xfmr_outer_leg_length_rel
xfmr_c_term
xfmr_use_linear_core
xfmr_core_knee_flux_mult
xfmr_core_knee_current_mult
xfmr_sc_resistance_pct
xfmr_core_linear_l_pu
xfmr_core_a_prime
xfmr_core_b_prime
Core modellingο
The magnetic branch is referred only to the from side:
v_core_w = v_f_w
i_core is injected only at the from terminal
This is more robust and closer to the classical transformer equivalent than the previous symmetric split of the core branch between both terminals.
Capacitive pathο
Terminal capacitances are represented through:
state charges q_f and q_t
algebraic currents i_cap_f and i_cap_t
q = C v
dq/dt = i_cap
If xfmr_c_term = 0, these states collapse consistently to zero.
Sign conventionο
Exported branch currents follow the VeraGrid branch convention: current is positive when it leaves the bus.
- param vf:
EMT variable factory.
- param conn_f:
Optional from-side winding connection.
- param conn_t:
Optional to-side winding connection.
- param name:
Symbolic model name.
- return:
EMT transformer template.