setReference pressure problem when having source term in pdEqn
Dear foamers,
I'm working on a problem dealing with evaporation and condensation of water inside a closed domain. The fixedFluxPressure boundary condition is applied on all the boundaries which necessitate the need for setting a reference pressure before solving the pdEqn. The evaporation-condensation model adds a mass transfer source in pdEqn as follow: Code:
fvScalarMatrix pdEqn http://uupload.ir/files/px21_u.png http://uupload.ir/files/5vfm_tem.png If it helps further investigating the issue, here is the full pEqn function: Code:
void interPhaseChangeFluid::pEqn D.Khazaei |
So just to clarify, the source term that you added is
Code:
(vDotc - vDotv) Anyways, so what I know so far is that solving the equation explicitly or implicitly does not seem to make a change (no influence of the matrix coefficients due to the implicit solver), I also thought that the source term may be multiplied by the volume but that doesn't change anything (also it seems strange, other threads on adding source terms to openfoam do not do this, but I tried anyway, I guess to calm my paranoia ...). Are you sure that the issue is due to the reference pressure? There is also a method called constrainPressure(), maybe that would help in your case? |
Quote:
Quote:
I think it has something to do with velocity prediction after solving for pd where the velocity is corrected using pdEqn.flux(). Quote:
explicit implementation: if you look into interPhaseChangeFoam and interCondensingEvaporatingFoam solvers it can be seen that this is a common approach. Code:
fvScalarMatrix pdEqn Code:
fvScalarMatrix pdEqn Code:
fvScalarMatrix pdEqn Code:
pd_.needReference() Code:
pdEqn.setReference(pRefCell, pdRefValue) Quote:
Quote:
However, I don't have any problem with the source term if I don't try to model a closed-domain. So my problem seems to be related to setting a reference pressure when having a source term in pEqn. Quote:
I don't think foam-extend has such a library called constrainPressure(), I will look into it. However, both adjustPhi and constrainPressure modify boundaries of the domain. My problem is not limited to boundaries, if I put the reference location inside the domain, then I will see unrealistic velocity and Temperature there. Regards |
my bad, could you then indicate what the correct velocity and temperature field should look like? (I presume it is just a homogeneous field of velocity and temperature, i.e. no spikes as seen in your contour plots then?)
It seems you have already put more effort into understanding the issue than I could, so I have some new ideas to try for my issue (thanks for that), but now that I understand your problem a bit better, I agree that our problems are probably fundamentally different. But if I understand that correctly, you do not have the issue when you use at least on one boundary a dirichlet condition for the pressure? I.e. the problem only arises when you have fully Neumann boundary conditions? I remember a similar problem when I was writing a simplified code for the lid driven cavity problem, there the pressure also has fully Neumann BCs and when prescribing a reference cell and value that approach was always giving wrong results for the cell where I put the reference pressure (similar to what you are showing). In the end I removed the reference pressure approach and just calculated the average pressure and removed that from the simulation (did the job, I guess you could say it is more of a global approach, whereas prescribing the reference cell could be seen as a local approach). Anyways, in openfoam that may not work as easily (and may also not be generalised for different cases), so I am not sure what to do about that. One thing I am a bit more surprised about is that the pressure field seems to be OK while the velocity field is not. They should be coupled and even if the issue is only within the velocity field, at the next update it should then also affect the pressure. Thats a bit odd. And the last thing, you said that you expect the problem to be with "pdEqn.flux()", but in-fact that method is always called (?!), while you say the issue only arises when if (pd_.needReference()) evaluates to true? Then I would expect the issue to be there, what makes you think it is the flux method then? (just trying to understand your thinking, maybe I missunderstood something along the way) |
Quote:
Yes, exactly. I have also installed ANSYS Fluent student version and performed the simulation there. There should never be such a spike in velocity and temperature fields and those fields should start changing smoothly as the simulation goes on. Quote:
Quote:
Quote:
When I was analyzing the same case with ANSYS Fluent, it says that to see the actual reference location you need to run the following TUI command which is only available when the simulation doesn't have any pressure related boundary conditions: Code:
define -> operating-conditions -> used-ref-pressure-location I have tried to remove pdEqn.setReference and that just cause immediate divergence. Quote:
Quote:
Maybe the solution doesn't converge properly when I insert the source and the pdEqn.setReference() is active simultaneously. Although that doesn't answer why pd_ field doesn't show any anomaly if there is a convergence problem. Code:
if (pimple_.finalNonOrthogonalIter()) |
I see, thanks for the additional explanation. This might not work (or be pointless), but what happens if you call pd_.correctBoundaryConditions(); ? And could you also explain what the pd equation actually solves?
Regarding the pressure boundary implementation, I lterally just looped over all cells, added the pressure to a counter and then diveded the counter by the number of elements. That was then my average pressure and I removed that from my pressure field. Or in pseudo code Code:
averagePressure = 0 I am actually not sure how fluent handles the reference pressure. You can specify your operational pressure which, for incompressible flows, should be anyways irrelevant. During post processing that value is used, however, to calculate your total pressure but I am not sure if the value is used in the simulation itself. |
Quote:
Well it's just the same as p_rgh in OpenFOAM, with different naming in foam-extend. It solves for the pressure subtracted by rho*gh. Quote:
Quote:
Regards |
today I have noticed something that I can't understand. I have modified the code to output pd_ values at each step:
Code:
fvScalarMatrix pdEqn I though that pdEqn.setReference is supposed to actually keep pd_ value at pRefCell constant. Am I wrong here? I think that may reveal why prediction of velocity using pdEqn.flux() causes non-physical values. If I remove the source term from pdEqn, then pd_ value remains constant at all the steps and I don't get non-physical velocity or temperature field anymore. |
ahhh, I see, in-fact, the following line doesn't make any sense (at least to me)
Code:
pdEqn.setReference(pRefCell_, getRefCellValue(pd_, pRefCell_)); Code:
pdEqn.setReference(pRefCell_, pRefValue); |
Quote:
Code:
//- re-evaluate pressure using additional terms Code:
p_ = pd_ + rho_*gh_; Code:
if (pd_.needReference()) Code:
pdEqn.setReference(pRefCell_, getRefCellValue(pd_, pRefCell_)); Code:
pdEqn.setReference(pRefCell_, pRefValue); The interesting think is that I tried using TEqn.setReference to enforce constant temperature at ref. cell but the exact same problem is there. If TEqn contains any source term then setReference can't keep T constant at the specified value. |
just looking for any reason behind this issue, I have just noticed that there is a bug report about it:
https://develop.openfoam.com/Develop...lus/issues/465 As I'm using the exact same mass transfer model in my solver, I think the same limitation is inherited: "The mass can not be conserved when any mass transfer model is involved." So, no closed-doamin for now until I have enough time to come up with a solution. Probably ANSYS found a solution for this, because it handles these kind of simulation without any problem. |
I see, well, half satisfying but at least we know its not your code then :)
|
1 Attachment(s)
Unfortunately, I got the same issue. Having no idea why and how to fix.
As you can see from my screenshot, the pressure spike is at the reference cell (pRefCell=0). This leads to a crash later. My solver for this case is buoyantSimpleFoam. Mesh quality is quite good, since the geometry is simple. Help needed and really appreciate in advance!!! |
All times are GMT -4. The time now is 04:36. |