def step( self, value ): super().step( value ) self.p_nodes, self.m_dot_pipes, self.m_dot_nodes, gas = \ pgsim._run_sim( self.net, level = 'BP' ) for attr in [ '{}/P'.format(k) for k in self.p_nodes.keys() ]: self.save_attribute( attr ) for attr in [ '{}/m_dot'.format(k) for k in self.m_dot_pipes.keys() ]: self.save_attribute( attr )
def test_run_sim(fix_create): net = fix_create p_nodes, m_dot_pipes, m_dot_nodes, gas = sim._run_sim(net) assert round(gas.rho, 3) == 0.017 assert p_nodes == {'BUS1': 2500.0, 'BUS2': 1962.7, 'BUS3': 1827.8} assert m_dot_pipes == { 'PIPE3': 6.6e-05, 'PIPE1': 0.000328, 'PIPE2': 0.000328 } assert m_dot_nodes == { 'BUS1': -0.000656, 'BUS2': 0.000262, 'BUS3': 0.000394 }
def __init__( self ): super().__init__() connect = PostgreSQLConnectionInfo( user = self.init_values[ 'dbuser' ], pwd = self.init_values[ 'dbpwd' ], host = self.init_values[ 'dbhost' ], port = self.init_values[ 'dbport' ], dbname = self.init_values[ 'dbname' ] ) pg_reader = PandaNGasModelDBReader( connect ) self.net = pg_reader.get_net( network_id = self.init_values[ 'network_id' ] ) print(self.net) self.p_nodes, self.m_dot_pipes, self.m_dot_nodes, gas = \ pgsim._run_sim( self.net, level = 'BP' )
def test_sim_utn_gas_pandangas(fix_connect, fix_gas_network_id): # Instantiate reader. pg_reader = PandaNGasModelDBReader(fix_connect) # Create simulation model from database. net = pg_reader.get_net(network_id=fix_gas_network_id) # Check number of elements in the simulation model. assert (len(net.station) == 1) assert (len(net.pipe) == 4) assert (len(net.feeder) == 1) assert (len(net.load) == 2) assert (len(net.bus) == 5) scaled_loads = gas_sim._scaled_loads_as_dict(net) assert (scaled_loads['node-N2'] == 0.000262) assert (scaled_loads['node-N3'] == 0.000394) p_min_loads = gas_sim._p_min_loads_as_dict(net) assert (p_min_loads['node-N2'] == 2200.0) assert (p_min_loads['node-N3'] == 2200.0) p_nom_feed = gas_sim._p_nom_feed_as_dict(net) assert (p_nom_feed['node-NF'] == 90000.0) assert (p_nom_feed['node-N1'] == 2500.0) #with pytest.warns( PendingDeprecationWarning ) as record: p_nodes, m_dot_pipes, m_dot_nodes, gas = gas_sim._run_sim(net) #assert( len( record ) == 1 ) assert (p_nodes['node-N1'] == 2500.0) assert (p_nodes['node-N2'] == 1962.7) assert (p_nodes['node-N3'] == 1827.8) assert (m_dot_pipes['pipe-N1-N2'] == 0.000328) assert (m_dot_pipes['pipe-N1-N3'] == 0.000328) assert (m_dot_pipes['pipe-N2-N3'] == 6.6e-05) assert (m_dot_nodes['node-N1'] == -0.000656) assert (m_dot_nodes['node-N2'] == 0.000262) assert (m_dot_nodes['node-N3'] == 0.000394)
def test_run_sim_mp(fix_create): net = fix_create_full_mp() p_nodes, m_dot_pipes, m_dot_nodes, gas = sim._run_sim(net, level="MP") assert round(gas.rho, 3) == 0.683 assert p_nodes == { 'BUS1': 89976.5, 'BUS2': 89957.3, 'BUS3': 89953.5, 'BUSF': 90000.0 } assert m_dot_pipes == { 'PIPE0': 0.001181, 'PIPE1': 0.000469, 'PIPE2': 0.00045, 'PIPE3': 7.5e-05 } assert m_dot_nodes == { 'BUSF': -0.001181, 'BUS1': 0.000262, 'BUS2': 0.000394, 'BUS3': 0.000525 }
def runpp(net, t_grnd=10+273.15): sorted_levels = sorted(net.LEVELS.items(), key=operator.itemgetter(1)) for level, value in sorted_levels: if level in net.bus["level"].unique(): logging.info("Compute level {}".format(level)) p_nodes, m_dot_pipes, m_dot_nodes, fluid = sim._run_sim(net, level, t_grnd) for node, value in p_nodes.items(): if node in net.bus["name"].unique(): idx = get_index(node, net.bus) net.res_bus.loc[idx] = [node, value] for pipe, m_dot in m_dot_pipes.items(): idx = get_index(pipe, net.pipe) v = _v_from_m_dot(net, pipe, m_dot, fluid) net.res_pipe.loc[idx] = [pipe, m_dot, v, m_dot * net.LHV, 100*v/net.V_MAX] for node, m_dot in m_dot_nodes.items(): if node in net.station["bus_low"].unique(): idx_stat = get_index(node, net.station, col="bus_low") stat = net.station.at[idx_stat, "name"] idx = get_index(stat, net.res_station) net.res_station.loc[idx] = [ stat, -m_dot, -m_dot * net.LHV, -100*m_dot*net.LHV/net.station.at[idx_stat, "p_lim_kW"] ] if node in net.feeder["bus"].unique(): idx_feed = get_index(node, net.feeder, col="bus") feed = net.feeder.at[idx_feed, "name"] idx = get_index(feed, net.res_feeder) net.res_feeder.loc[idx] = [ feed, m_dot, m_dot * net.LHV, 100*m_dot*net.LHV/net.feeder.at[idx_feed, "p_lim_kW"] ]