how does the periodic routine calculate pressure gradient

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
asda9786
Posts: 7
Joined: Mon Apr 01, 2019 12:00 pm

how does the periodic routine calculate pressure gradient

Post by asda9786 »

Hi everyone, I have incorporated a periodic subroutine for my simulation set at the inlet and outlet of my model provided by a colleague. I have attached the code below. It governs the fluid flow. I am trying to understand the code. I am unsure how it calculates the pressure gradient that can be seen at the end of the listing file. My question is how does it calculate the pressure gradient ?
Attachments
cs_user_source_terms.f90
(35.96 KiB) Downloaded 169 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: how does the periodic routine calculate pressure gradient

Post by Yvan Fournier »

Hello,

I am not sure I understand correctly, but in the case of a uniform velocity source term applied to the whole domain, I understand such a source term is equivalent to a change of variable so that the "equivalent" pressure can be periodic. As the source term basically compensates for the pressure drop in the Navier-Stokes equations, the term computed/adjusted so as to provide a given flow rate is equivalent to an average pressure gradient.

Regards,

Yvan
asda9786
Posts: 7
Joined: Mon Apr 01, 2019 12:00 pm

Re: how does the periodic routine calculate pressure gradient

Post by asda9786 »

Hello Yvan,

I understand the flow rate is constant across the domain due to periodic conditions. But I was trying to understand how the pressure gradient is calculated in the listing file. Because I am comparing it to an experimental pressure drop value based on a frictional factor. The two values match well,

I just don't know how to explain how the Code saturne simulation calculates this value. I would like to understand the theory of how code saturne uses the source term subroutine to generate a pressure gradient, equivalent to the pressure gradient in the traditional navier stokes equation.
I may be overthinking this point, If I were to simulate using a different CFD package I would get a pressure drop based on the RANS eqautions. How does this deviate from the way Code-Saturne calculates the pressure drop using the source term. Or is it the exact same method.

Hope this made more sense
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: how does the periodic routine calculate pressure gradient

Post by Yvan Fournier »

Hello,

I suppose it is the same method. Code_Saturne does not compute the pressure drop based on the source term, but based on the differential operators used in the simulation. The source term allows to compensate for the pressure drop in the periodic domain due to viscous terms (the pressure needs to be periodic also; with no source term, the stable solution would be "uniform pressure/zero velocity").

Regards,

Yvan
asda9786
Posts: 7
Joined: Mon Apr 01, 2019 12:00 pm

Re: how does the periodic routine calculate pressure gradient

Post by asda9786 »

Okay that makes more sense thank you. I will try to investigate further maybe look through some documents.
Thanks for the help though!!!!
asda9786
Posts: 7
Joined: Mon Apr 01, 2019 12:00 pm

Re: how does the periodic routine calculate pressure gradient

Post by asda9786 »

Hi there,
I think I have overlooked this completely. But If you could just answer this question, that would be great. Essentially the pressure gradient is calculated by measuring the pressure at the inlet and outlet, then working out the difference. Is that correct?


Thank you
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: how does the periodic routine calculate pressure gradient

Post by Yvan Fournier »

Hello,

No, the gradient is local to each cell, an not computed simply from the inlet and outlet.

So the "gradient" in the listing is not a real gradient, but probably an average gradient value.

If your really need to understand how the gradient is computed, check src/alge/cs_gradient.c and/or the theory manual.

Regards,

Yvan
Post Reply