Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name,base_power_MVA,base_voltage_kV,base_frequency_Hz,minimum_voltage_pu,maximum_voltage_pu
lima,1.00E+02,2.30E+02,60,1,1
santiago,1.00E+02,2.30E+02,60,0.95,1.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name,from_bus,to_bus,base_power_MVA,base_voltage_kV,base_frequency_Hz,r_pu,x_pu,g_pu,b_pu
tx_1,lima,santiago,1.00E+02,2.30E+02,60,0.01,0.5,0.05,0.066666667
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bus,timepoint,load_MW,load_MVAR
lima,t_1,0,0
santiago,t_1,0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name,bus,minimum_active_power_MW,maximum_active_power_MW,minimum_reactive_power_MVAR,maximum_reactive_power_MVAR,base_power_MVA,base_voltage_kV,base_frequency_Hz,cost_variable_USDperMWh,r_pu,x_pu,inertia_constant_s,damping_pu
gen1,lima,-200,200,-500,500,1.00E+02,2.30E+02,60,0,0.01,0.5,3,1
gen2,santiago,100,100,74,75,1.00E+02,2.30E+02,60,0,0.05,0.2,3,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name
t_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bus,timepoint,generator_dispatch_MW,load_shedding_MW,load_MW,net_line_leaving_flow_MW
lima,t_1,-85.86698271936963,-9.97494096261266e-9,0.0,-85.86698272918828
santiago,t_1,100.0,-9.974940980027277e-9,0.0,99.99999998988655
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,bus,timepoint,voltage_magnitude_pu,voltage_angle_deg
0,lima,t_1,1.0,0.0
1,santiago,t_1,1.2780887210409115,20.643650769134787
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
component,cost
total_cost_USD,-0.00003989976382117789
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,type,generator,timepoint,active_power_MW,reactive_power_MVAR
0,sources_with_swing,gen1,t_1,-85.86698271936963,-44.05416612599554
1,sources_with_swing,gen2,t_1,100.0,74.77059585403816
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
line,from_bus,to_bus,existing_capacity_MW,active_power_from_bus_MW,reactive_power_from_bus_MVAR,active_power_to_bus_MW,reactive_power_to_bus_MVAR,active_power_loss_MW,reactive_power_loss_MVAR
tx_1,lima,santiago,inf,-85.86698272918831,-44.0541661359936,99.99999998988658,74.77059584444507,14.133017260698267,30.71642970845147
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bus,timepoint,active_load_shedding_MW,reactive_load_shedding_MVAR
lima,t_1,-9.97494096261266e-9,-9.974940964279889e-9
santiago,t_1,-9.974940980027277e-9,-9.97494091425806e-9
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bus,timepoint,generator_dispatch_MVAR,load_shedding_MVAR,load_MVAR,net_line_leaving_flow_MVAR
lima,t_1,-44.05416612599554,-9.974940964279889e-9,0.0,-44.054166135993555
santiago,t_1,74.77059585403816,-9.97494091425806e-9,0.0,74.77059584444504
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
attribute,value
solver_name,ipopt
solver_status,ok
termination_condition,optimal
time_spent_seconds,0.021149158477783203
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Index,"('sources_with_swing_0', 'i_bus_D')","('sources_with_swing_0', 'i_bus_Q')","('sources_with_swing_1', 'i_bus_D')","('sources_with_swing_1', 'i_bus_Q')","('shunt_parallel_rc_0', 'v_bus_D')","('shunt_parallel_rc_0', 'v_bus_Q')","('shunt_parallel_rc_1', 'v_bus_D')","('shunt_parallel_rc_1', 'v_bus_Q')","('branch_series_rl_0', 'i_br_D')","('branch_series_rl_0', 'i_br_Q')"
"('sources_with_swing_0', 'p_m')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_ref_d')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_ref_q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_bus_D')",0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'p_m')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'v_ref_d')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'v_ref_q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0
"('sources_with_swing_1', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0
"('shunt_parallel_rc_0', 'i_bus_D')",1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,0.0
"('shunt_parallel_rc_0', 'i_bus_Q')",0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0
"('shunt_parallel_rc_1', 'i_bus_D')",0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0
"('shunt_parallel_rc_1', 'i_bus_Q')",0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0
"('branch_series_rl_0', 'v_from_bus_D')",0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_from_bus_Q')",0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_to_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_to_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Index,"('sources_with_swing_0', 'p_m')","('sources_with_swing_0', 'v_ref_d')","('sources_with_swing_0', 'v_ref_q')","('sources_with_swing_1', 'p_m')","('sources_with_swing_1', 'v_ref_d')","('sources_with_swing_1', 'v_ref_q')"
"('sources_with_swing_0', 'p_m')",1.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_ref_d')",0.0,1.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_ref_q')",0.0,0.0,1.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'p_m')",0.0,0.0,0.0,1.0,0.0,0.0
"('sources_with_swing_1', 'v_ref_d')",0.0,0.0,0.0,0.0,1.0,0.0
"('sources_with_swing_1', 'v_ref_q')",0.0,0.0,0.0,0.0,0.0,1.0
"('sources_with_swing_1', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'i_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'i_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'i_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'i_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_from_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_from_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_to_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'v_to_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Index,"('sources_with_swing_0', 'i_bus_D')","('sources_with_swing_0', 'i_bus_Q')","('sources_with_swing_1', 'i_bus_D')","('sources_with_swing_1', 'i_bus_Q')","('shunt_parallel_rc_0', 'v_bus_D')","('shunt_parallel_rc_0', 'v_bus_Q')","('shunt_parallel_rc_1', 'v_bus_D')","('shunt_parallel_rc_1', 'v_bus_Q')","('branch_series_rl_0', 'i_br_D')","('branch_series_rl_0', 'i_br_Q')"
"('sources_with_swing_0', 'i_bus_D')",1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'i_bus_Q')",0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'i_bus_D')",0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'i_bus_Q')",0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'v_bus_D')",0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0
"('branch_series_rl_0', 'i_br_D')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0
"('branch_series_rl_0', 'i_br_Q')",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Index,"('sources_with_swing_0', 'p_m')","('sources_with_swing_0', 'v_ref_d')","('sources_with_swing_0', 'v_ref_q')","('sources_with_swing_1', 'p_m')","('sources_with_swing_1', 'v_ref_d')","('sources_with_swing_1', 'v_ref_q')"
"('sources_with_swing_0', 'i_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_0', 'i_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'i_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('sources_with_swing_1', 'i_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_0', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'v_bus_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('shunt_parallel_rc_1', 'v_bus_Q')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'i_br_D')",0.0,0.0,0.0,0.0,0.0,0.0
"('branch_series_rl_0', 'i_br_Q')",0.0,0.0,0.0,0.0,0.0,0.0
75 changes: 75 additions & 0 deletions examples/small_signal_and_emt/2-bus_2-src_swing/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
Simulates two sources with swing dynamics connected via a transmission line.

First, we compute the system-wide small-signal model using STING.
This small-signal model also contains EMT initial conditions.

You should obtain the following eigenvalues:
shape: (14, 5)
┌──────────┬───────────┬──────────────────────┬──────────────────┬───────────────────────┐
│ real ┆ imag ┆ natural_frequency_hz ┆ damping_ratio_pu ┆ time_constant_seconds │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞══════════╪═══════════╪══════════════════════╪══════════════════╪═══════════════════════╡
│ 0.0 ┆ 0.0 ┆ 0.0 ┆ -1.0 ┆ -2.6276e7 │
│ -0.063 ┆ 8.892 ┆ 1.415 ┆ 0.007 ┆ 15.8731 │
│ -0.063 ┆ -8.892 ┆ 1.415 ┆ 0.007 ┆ 15.8731 │
│ -0.163 ┆ 0.0 ┆ 0.026 ┆ 1.0 ┆ 6.1304 │
│ -21.987 ┆ 376.796 ┆ 60.071 ┆ 0.058 ┆ 0.0455 │
│ -21.987 ┆ -376.796 ┆ 60.071 ┆ 0.058 ┆ 0.0455 │
│ -159.587 ┆ 2149.013 ┆ 342.968 ┆ 0.074 ┆ 0.0063 │
│ -159.587 ┆ -2149.013 ┆ 342.968 ┆ 0.074 ┆ 0.0063 │
│ -159.589 ┆ 2902.987 ┆ 462.722 ┆ 0.055 ┆ 0.0063 │
│ -159.589 ┆ -2902.987 ┆ 462.722 ┆ 0.055 ┆ 0.0063 │
│ -166.836 ┆ 3750.796 ┆ 597.548 ┆ 0.044 ┆ 0.006 │
│ -166.836 ┆ -3750.796 ┆ 597.548 ┆ 0.044 ┆ 0.006 │
│ -166.837 ┆ 4504.775 ┆ 717.449 ┆ 0.037 ┆ 0.006 │
│ -166.837 ┆ -4504.775 ┆ 717.449 ┆ 0.037 ┆ 0.006 │
└──────────┴───────────┴──────────────────────┴──────────────────┴───────────────────────┘
"""

# Import Python standard and third-party packages
from pathlib import Path
# Import sting package
from sting import main
from sting.system.core import System
import os
import numpy as np
import polars as pl

# Specify path of the case study directory
case_dir = Path(__file__).resolve().parent

# Step function inputs to simulate
def step1(t):
return 0.01 if t >= 0.5 else 0.0

def step2(t):
return 0.0

inputs = {
'sources_with_swing_0': {
'v_ref_d': step1
},
'sources_with_swing_1': {
'v_ref_d': step2
}
}
t_max = 1.0 # Simulation length in seconds

# Construct system and small-signal model
sys, ssm = main.run_ssm(case_directory=case_dir)
ssm.simulate_ssm(t_max=t_max, inputs=inputs)

# Run EMT simulation
main.run_emt(case_directory=case_dir, inputs=inputs, t_max=t_max)

emt_dir = os.path.join(case_dir, "outputs", "simulation_emt")
ssm_dir = os.path.join(case_dir, "outputs", "small_signal_model")

ans = dict()
for component in sys:
if hasattr(component, "compare_ssm_emt"):
ans |= getattr(component, "compare_ssm_emt")(emt_dir, ssm_dir)

mprint("\nok")
2 changes: 2 additions & 0 deletions sting/generator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Generator(Component):
base_power_MVA: float = None
base_voltage_kV: float = None
base_frequency_Hz: float = None
damping_pu: float = None
inertia_constant_s: float = None
technology: str = None
site: str = None
cap_existing_power_MW: float = None
Expand Down
Loading