Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit default output writer #651

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/pandapipes/test/pipeflow_internals/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _data_source():


def _compare_results(ow):
_compare_results_default_ow(ow)
test_res_ext_grid = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_ext_grid',
'mdot_kg_per_s.csv'), sep=';', index_col=0)
res_ext_grid = ow.np_results["res_ext_grid.mdot_kg_per_s"]
Expand All @@ -87,6 +88,25 @@ def _compare_results(ow):
diff = 1 - res_ext_grid.round(9) / test_res_ext_grid.round(9)
check = diff < 0.0001
assert (np.all(check))
test_res_sink = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_sink',
'mdot_kg_per_s.csv'), sep=';', index_col=0)
res_sink = ow.np_results["res_sink.mdot_kg_per_s"]
res_sink = res_sink[~np.isclose(res_sink, 0)]
test_res_sink = test_res_sink.values[~np.isclose(test_res_sink.values, 0)]
diff = 1 - res_sink.round(9) / test_res_sink.round(9)
check = diff < 0.0001
assert (np.all(check))
test_res_source = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_source',
'mdot_kg_per_s.csv'), sep=';', index_col=0)
res_source = ow.np_results["res_source.mdot_kg_per_s"]
res_source = res_source[~np.isclose(res_source, 0)]
test_res_source = test_res_source.values[~np.isclose(test_res_source.values, 0)]
diff = 1 - res_source.round(9) / test_res_source.round(9)
check = diff < 0.0001
assert (np.all(check))


def _compare_results_default_ow(ow):
test_res_junction = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_junction',
'p_bar.csv'), sep=';', index_col=0)
res_junction = ow.np_results["res_junction.p_bar"]
Expand All @@ -103,22 +123,6 @@ def _compare_results(ow):
diff = 1 - res_pipe.round(9) / test_res_pipe.round(9)
check = diff < 0.0001
assert (np.all(check))
test_res_sink = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_sink',
'mdot_kg_per_s.csv'), sep=';', index_col=0)
res_sink = ow.np_results["res_sink.mdot_kg_per_s"]
res_sink = res_sink[~np.isclose(res_sink, 0)]
test_res_sink = test_res_sink.values[~np.isclose(test_res_sink.values, 0)]
diff = 1 - res_sink.round(9) / test_res_sink.round(9)
check = diff < 0.0001
assert (np.all(check))
test_res_source = pd.read_csv(os.path.join(data_path, 'test_time_series_results',
'res_source', 'mdot_kg_per_s.csv'), sep=';', index_col=0)
res_source = ow.np_results["res_source.mdot_kg_per_s"]
res_source = res_source[~np.isclose(res_source, 0)]
test_res_source = test_res_source.values[~np.isclose(test_res_source.values, 0)]
diff = 1 - res_source.round(9) / test_res_source.round(9)
check = diff < 0.0001
assert (np.all(check))


def _output_writer(net, time_steps, ow_path=None):
Expand Down Expand Up @@ -173,7 +177,7 @@ def test_time_series_default_ow():
max_iter_hyd = 8
run_timeseries(net, time_steps, max_iter_hyd=max_iter_hyd, calc_compression_power = False)
ow = net.output_writer.iat[0, 0]
_compare_results(ow)
_compare_results_default_ow(ow)


if __name__ == "__main__":
Expand Down
3 changes: 0 additions & 3 deletions src/pandapipes/timeseries/run_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def init_default_outputwriter(net, time_steps, **kwargs):
net.output_writer.iat[0, 0] = output_writer
if "output_writer" not in net or net.output_writer.iat[0, 0] is None:
ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), log_variables=[])
ow.log_variable('res_sink', 'mdot_kg_per_s')
ow.log_variable('res_source', 'mdot_kg_per_s')
ow.log_variable('res_ext_grid', 'mdot_kg_per_s')
ow.log_variable('res_pipe', 'v_mean_m_per_s')
ow.log_variable('res_junction', 'p_bar')
ow.log_variable('res_junction', 't_k')
Expand Down