Reputation: 183
I know that one can calculate the measurements of a network also with the help of the jacobian matrix. I would like in pandapower to actually do this once manually and then compare with what is internally calculated, but my results do not make any sense. Maybe someone here would know how to actually do this?
net = pp.create_empty_network()
# Add buses
tso_bus = pp.create_bus(net, vn_kv=220, name=1, max_vm_pu = 1.06, min_vm_pu=0.94)
lv_bus_in_tso = pp.create_bus(net, vn_kv=20, name=2, max_vm_pu = 1.06, min_vm_pu=0.94)
dso_bus = pp.create_bus(net, vn_kv=20, name=3, max_vm_pu = 1.06, min_vm_pu=0.94)
# Add an external grid connection to serve as the reference bus for the TSO part
pp.create_ext_grid(net, bus=tso_bus, vm_pu=1.02, name="External Grid")
# Add a generator to the TSO bus
pp.create_gen(net, bus=tso_bus, p_mw=80.13933714119322715, vm_pu=1.02, name="TSO Generator", controllable = True, min_p_mw = 0, max_p_mw=100)
#pp.create_gen(net, bus=tso_bus, p_mw=100, vm_pu=1.02, name="TSO Generator", controllable = True, min_p_mw = 0, max_p_mw=100)
# Add loads to the TSO and DSO buses
pp.create_load(net, bus=tso_bus, p_mw=50, q_mvar=20, name="TSO Load", controllable = False)
pp.create_load(net, bus=dso_bus, p_mw=30, q_mvar=10, name="DSO Load", controllable = False)
# Add a transformer between the TSO and DSO parts
pp.create_transformer_from_parameters(
net, hv_bus=tso_bus, lv_bus=lv_bus_in_tso,
sn_mva=60, vn_hv_kv=220, vn_lv_kv=20,
vk_percent=10, vkr_percent=0.5, pfe_kw=30, i0_percent=0.1, shift_degree=30,
tap_neutral=0, tap_pos=0,
name="TSO-DSO Transformer"
)
# Connect the LV side of the transformer to the DSO bus
pp.create_line_from_parameters(net, from_bus=lv_bus_in_tso, to_bus=dso_bus,
length_km=0.1, r_ohm_per_km=0.1, x_ohm_per_km=0.1, c_nf_per_km=0, max_i_ka=1)
# Step 2: Run power flow analysis on the unified network
pp.runpp(net)
# Compute state matrix
H= net["_ppc"]["internal"]["J"].todense()
# Assuming you have run power flow on the network 'net'
# Get the slack bus index
slack_bus = net.ext_grid["bus"].values[0]
# Convert angles from degrees to radians
angles_radians = np.radians(net.res_bus.va_degree.drop(slack_bus).values)
# Get voltage magnitudes for all buses (in per unit)
voltages = net.res_bus.vm_pu.drop(slack_bus).values
# Construct the state vector (angles in radians, voltages in pu)
state_vector = np.concatenate((angles_radians, voltages))
# Perform the matrix multiplication H * state_vector
Hx = H @ state_vector
print("H * state_vector:", Hx)
in comparison to
Upvotes: 0
Views: 55