def test_branch_order(): np_assert_equal( Incidence(n).get_index('branch'), network_flow(n, snapshots=n.snapshots[0]).get_index('branch')) pbc = n.passive_branch_components np_assert_equal( Incidence(n, branch_components=pbc).get_index('branch'), network_flow(n, snapshots=n.snapshots[0], branch_components=pbc).get_index('branch'))
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_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_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)