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

Flow direction and compressors #562

Open
OriolRaventos opened this issue Sep 6, 2023 · 4 comments
Open

Flow direction and compressors #562

OriolRaventos opened this issue Sep 6, 2023 · 4 comments

Comments

@OriolRaventos
Copy link

If I understand corretly from the documentation:

  • A source injects some mass flow specified in mdot_kg_per_s as a positive number
  • A sink draws some mass flow specified in mdot_kg_per_s as a positive number as well
  • In the results of an external grid the mdot_kg_per_s is negative if leaving the system (and positive if entering)

Possible typo: In the documentation of the sink, I guess there is a typo on the Component Table Data, since gives a Value Range for mdot_kg_per_s a $\leq 0$, but it should be $\geq 0$. See here.

Now, I cannot understand the results of the following simple 3-node example derived from here.

import pandapipes as pp

net = pp.create_empty_network("net", add_stdtypes=False)

# fluid
pp.create_fluid_from_lib(net, "hgas", overwrite=True)

# junctions
pp.create_junction(net, index=3, pn_bar=16, tfluid_k=283, height_m=0,
    name="Junction 3", in_service=True,
    type="junction", geodata=(0,0))
pp.create_junction(net, index=9, pn_bar=16, tfluid_k=283, height_m=0,
    name="Junction 9", in_service=True,
    type="junction", geodata=(1,0))
pp.create_junction(net,index=10, pn_bar=16, tfluid_k=283, height_m=0,
    name="Junction 10", in_service=True,
    type="junction", geodata=(2,0))

# pipes
pp.create_pipe_from_parameters(
	net, 9, 10, length_km=1, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1,
	name="Pipe 6")

# sinks
pp.create_sink(net, 9, mdot_kg_per_s=0.01, name="Sink 3")

# sources
pp.create_source(net, junction=10, mdot_kg_per_s=0.04, name="Source 3")

# compressor
pp.create_compressor(net, from_junction=9, to_junction=3, pressure_ratio=1.1,
	name="Compressor 0", index=None, in_service=True)

# aggregate the rest of the grid
# as external grid with given pressure
pp.create_ext_grid(net, junction=3, p_bar=15)

After running the flow simulation:

pp.pipeflow(net)

I got the following flow for the diferent components:

  • ext_grid at 3 = +0.03
  • compressor from 9 to 3 = -0.03
  • pipe from 9 to 10 = +0.04
  • source at 10 = +0.04
  • sink at 9 = +0.01

and I ask myself how can it be to have a +0.04 flow from 9 to 10 in the pipe, when at 10 there is a source of +0.04?

A somehow unrelated question: I tried to implement the external grid fixing the temperature instead of the pressure and it never converged for whatever values I gave. I also tried to substitute the external grid by a simple source with mass flow of 0.03 (and many other values) but it didn't converge either.

@dlohmeier
Copy link
Collaborator

Dear @OriolRaventos,

thank you for raising the issue. I will try to make the quick fix concerning the docs you mentioned wrt. the sink.

Concerning your question, I am not quite sure how you did interpret the results from the res_pipe table, but in my case, the velocity as well as volume flow and "mdot_from_kg_per_s" are given as negative values, indicating that the flow is directed from the "to_junction" to the "from_junction". Probably, the resulting table is not the most intuitive to interpret, I would be happy to take suggestions on improving it.

What concerns me is that the ext_grid result is positive, which seems to be a consequence of the "sign" of the component being positive. Is this intended, @SimonRubenDrauz ? If so, we need to change the documentation, otherwise the component model, as the result is positive in case of mass flow leaving the system.

Regarding your other question, could you provide an example? Did you just replace p_bar=15 by t_k=300 (or similar) in your script? In that case, what happens is that the hydraulic connectivity check will not find any node with a boundary condition for the pressure, setting everything out of service (you should be getting a logger output stating that junctions and pipe nodes are set out of service). Then your pipeflow is corrupted and doesn't work anymore. However, this would be a very simple case to identify and just stop the pipeflow with an adequate error message. Didn't we have similar issues already, @SimonRubenDrauz ?

So, you will always need one node with fixed pressure level, which is what the ext_grid provides in case it is a "p" or "pt" ext_grid. If you would like to set both pressure and temperature, you can give both parameters, in that case the calculation should converge. I hope that helps.

Kind regards

dlohmeier added a commit to dlohmeier/pandapipes that referenced this issue Sep 6, 2023
@OriolRaventos
Copy link
Author

Dear @dlohmeier,

Thank you very much for your quick response. Let me give you a short feedback:

  • Yes, you are right about the direction of the pipe (I was reading the "to" column instead of the "from" column.
  • I guess that the documentation is wrong about the Ext_grid: In the result data table it should sat " (positive if leaving the system)" (I checked that by switching the sink and the source in the example above).
  • Thank you for the hint about the pressure bounary conditions. Effectively, I just use t_k instead of p_n in the Ext_grid. But I did not get any logger about the non-connectivity or setting everything out of service, it just says "The hydraulic calculation did not converge to a solution". Do I understand it correctly that it is not possible to build the previous example by replacing the Ext_grid by a source like here below (since then I would have no pressure boundary condition)?
pp.create_source(net, junction=3, mdot_kg_per_s=0.03, name="Source 3")

Thanks again for all you help. This clarifies my issues. I'll wait a couple of days, in case you want to add any other input and then I will close the Issue.

@SimonRubenDrauz
Copy link
Collaborator

Dear @OriolRaventos and @dlohmeier,

  • thanks for raising the questions. Regarding the sign in terms of the external grid. I understand your remark and would recommend that we change the sign in terms of the external grid. I cannot remember why we did it that way, but I also think it is confusing that way, especially as pandapower is also doing it the other way round (feed-in is positive, consumption negative). What do you think, @dlohmeier?
  • Regarding your logger question. The level of the logger is by default WARNING. The connectivity check messages are INFO. Please change the level of your logger by calling logging.basicConfig(level='INFO')
  • As you already pointed out, it is not possible to replace an external grid by a source as the system would be underdetermined. You always need at least one fixed pressure node in your system.
  • One more important thing: In pandapipes you are able to perform hydraulic and heat transfer calculations. The hydraulic needs to be conducted first and defines the input for the heat transfer calculation (only applicable for water grids right now); i.e., hydraulic and heat transfer are currently detached from each other. Long story short, in both cases you need an external grid with a fixed pressure (hydraulic) and a fixed temperature (heat transfer). It can be the same external grid, but you can also define different external grids. The important thing for you: p and t are not interchangeable.
  • @dlohmeier, regarding your question with the error message: We had the same issue before, however, we did not think of the connectivity check. Thus, we defined a warning and it is only raised if there are no components defined at all. I guess, we should move the logger warning after the connectivity check!

I hope I was able to answer all of your questions. Best regards!

@OriolRaventos
Copy link
Author

Thank you very much. That claifies all my points.

About the signs. I do think that it would be more natural to keep the PandaPower convention.

Please, feel free to close this issue. I leave it open in case you want to link it to future change in the sign convention in the code. Thank once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants