def test_eqivalent_bilateral_exchanges_direct(): sn = n.snapshots[0] A = ntl.flow.flow_allocation(n, sn, method='ebe', aggregated=False) total_injection = A.virtual_injection_pattern.sum('injection_pattern') assert_allclose(total_injection, network_injection(n, sn), **tol_kwargs) total_flow = A.virtual_flow_pattern.sum('bus') assert_allclose(total_flow, network_flow(n, sn), **tol_kwargs)
def test_marginal_participation_direct(): sn = n.snapshots[0] A = ntl.flow.flow_allocation(n, sn, method='mp', aggregated=False) total_injection = A.virtual_injection_pattern.sum('injection_pattern') assert_allclose(total_injection, network_injection(n, sn), **tol_kwargs) total_flow = A.virtual_flow_pattern.sum('bus') assert_allclose(total_flow, network_flow(n, sn), **tol_kwargs)
def test_zbus_linear(): sn = n_mini.snapshots A = ntl.flow.flow_allocation(n_mini, sn, method='zbus') total_injection = A.virtual_injection_pattern.sum('injection_pattern') assert_allclose(total_injection, network_injection(n_mini, sn), **tol_kwargs) total_flow = A.virtual_flow_pattern.sum('bus') assert_allclose(total_flow, network_flow(n_mini, sn).T, **tol_kwargs)
def test_average_participation_direct(): sn = n.snapshots[0] K = ntl.Incidence(n) A = ntl.flow.flow_allocation(n, sn, method='ap', aggregated=False) # check total injection total_injection = A.peer_to_peer.sum('sink') target = power_production(n, sn).rename(bus='source') assert_allclose(total_injection, target, **tol_kwargs) # check total flow for peer_on_branch_to_peer total_flow = A.peer_on_branch_to_peer.sum(['source', 'sink']) assert_allclose(total_flow, network_flow(n, sn), **tol_kwargs) # check ingoing flow for peer_on_branch_to_peer sinkflow = A.peer_on_branch_to_peer.sum('source') assert_allclose((sinkflow @ K).sum('sink'), network_injection(n, sn), **tol_kwargs)
def test_bus_order(): comps = n.passive_branch_components assert network_injection(n, branch_components=comps).get_index('bus')\ .equals(Incidence(n, branch_components=comps).get_index('bus'))
def test_injection(): comps = n.passive_branch_components np_assert_allclose( network_injection(n, branch_components=comps).values, n.buses_t.p.values, **tol_kwargs)