MethodOfLines.jl
MethodOfLines.jl copied to clipboard
MOL & BoundaryConditions
** Does MOL support BCs including Algebraic Equations❓**
I'm trying to solve a "realistic"/"engineering" type PDE system with MOL. Most (every?) example I have seen of the use of MOL just contains PDEs for equations, and simple boundaries for BCs. In my case, I consider a two phase system of liquid and gas; a gas-lift system as used in oil production. I have 3 PDEs + numerous AEs (algebraic equations) within the system volume.
Then I have boundary conditions, typically represented by pressures outside of the pipe and flow of mass through valves governed by pressure differences.
The documentation is not very clear to me whether MOL allows for a mixture of PDEs and AEs, and BCs with AEs.
Here is a sketch of the system I consider with boundaries:
- Liquid (oil+water) enters at x=0 from an oil reservoir at pressure p_f.
- Gas enters at x=0 from an annulus pipe surrounding the tubing pipe that I consider; annulus pressure is p_a.
- The mixture (two phase) leaves the pipe at x=L towards a production manifold pressure p_p.
The gas and liquid flows as two separate phases, and may take up varying cross sectional areas given by variable alpha:
When I run my code, I get an error message when I try to discretize the model into DAEs: I'm told there is an illegal boundary condition.
To make my problem clearer, here are the PDEs valid within x=(0,L):
In addition, I have the following AEs which are also valid within x=(0,L):
In my model, in general, m is mass, fracture m is momentum, so two mass balances (liquid, gas) and a total momentum balance. The check decoration ("v") indicates "per volume". A dot on top (".") indicates flow rate. p is pressure, etc. For initial simplification, I have assumed that liquid density is constant (in reality, slightly compressible), and I have used a simplified gas EquationOfState which is almost an ideal gas but with compressibility factor z_g set to constant; in a more realistic model, z_g is the real root of a cubic polynomial. That will come in later.
My BCs are a mixture of traditional BCs and some AEs:
The last of the BCs I've listed (pressure gradient) is probably incorrect... because of gravity and friction, I don't think the gradient should be zero. Also, I already have 3 BCs related to the three external pressures p_f, p_a, p_p, and I have 3 PDEs with first order derivatives -- not sure if the pressure gradient should be counted in.
When I try to create the problem, I get an error message:
> prob = discretize(gas_lift,discr_scheme);
AssertionError: Boundary condition ṁ_a2t(t) ~ Y_a2t(t)*sqrt((max(Δp_a2t(t), 0)*ρ_a(t)) / (p_at2__ς*ρ_a2t__ς))*f_v(u_a2t(t))*ṁ_a2t__c is not on a boundary of the domain, or is not a valid boundary condition
NOTE: If someone knowledgeable would like to test what is wrong with my code, let me know.