Hi Alex,
I attached the relevant pieces of code in the file. Just to make sure we talk
about the same thing: in the mpnc model there are N+M equations/primary
variables for an isothermal system. This gives 5 equations for the 2p3c case
and the primary variables are: Sg, pg, and three fugacities. The pressure and
saturation are associated with the nonlinear complementarity functions (NCP
equations), so it seems like if I set the pressure and saturation on a boundary
but do not specify the mole fractions/fugacities, they are allowed to run wild
and the solution is f***ed up :).
I have a 2p2c fluidsystem at hand and tried it with that as well but the
problem is the same. Seems like there is no easy solution to this.
Georg
Von: Dumux [mailto:[email protected]] Im Auftrag von
Alexander Kissinger
Gesendet: Donnerstag, 13. August 2015 15:44
An: DuMuX User Forum
Betreff: Re: [DuMuX] Boundary conditions
Dear Georg,
I am not quite sure what causes your problem. Could you send the implementation
of your boundary conditions, i.e. your boudaryTypes() and your dirichlet()
function from your problem?
You could also try the following:
1. Just set the pressure as a Dirichlet condition and make the other two
equations outflow BC.
2. Try it with a 2p2c transport only system (set the third component to zero
everywhere), do you still get unphysical values?
Best regards
Alex
On 08/13/2015 01:56 PM, [email protected]<mailto:[email protected]> wrote:
Hi Alex,
I tried to do the same thing as in the 1p2coutflowproblem only with a 2p3c
Fluidsystem and the mpnc model. Initially, only the gas phase is present in the
whole domain (Sg=1) and I set Dirichlet boundary conditions for all primary
variables on the inlet (pg = 1.6 bar, Sg=1 and the mole fractions/fugacities).
Then I set Dirichlet conditions for pressure and saturation on the outlet
(Sg=1, pg=1.5 bar). The Dirichlet conditions are consistent with the initial
conditions. For the component conservation equations I set outflow conditions
on the outlet.
With these boundary conditions, everything should flow from the inlet to the
outlet due to the pressure gradient of the gas phase. The gas phase
composition may change on the way to the outlet due to reactions: 1 species is
consumed, another produced. With the outflow bc everything that reaches the
outlet should be allowed to leave the domain. Sadly, this is not working.
I get unphysical mole fractions at the outlet (x > 1). Any clues why this does
not work? Is the outflow condition used anywhere in a 2p-system?
Best regards
Georg
Von: Dumux [mailto:[email protected]] Im Auftrag von
Alexander Kissinger
Gesendet: Freitag, 31. Juli 2015 16:21
An: DuMuX User Forum
Betreff: Re: [DuMuX] Boundary conditions
Dear Georg,
If I understand correctly this means that whatever is on an outflow boundary is
allowed to flow out or into the system. So if we assume pure fickian diffusion
and the concentration in the domain is higher than on the boundary stuff will
flow out while it is vice versa if the concentration is lower. If that is the
case, what exactly is the difference to a Dirichlet boundary condition? As far
as I see, with this type of boundary condition I would keep e.g. a
concentration on the boundary constant. Am I correct?
In the case of pure fickian diffusion (no advection i.e. constant pressure) the
concentration at your outflow boundary would increase until the concentration
gradient is zero i.e. no more flow. The difference between a Dirchlet boundary
is that your concentration at the boundary dof is allowed to change with an
outflow BC.
Consider this example where the outflow boundary is more useful:
1d flow and transport in a tube (model: 1p2c). Left boundary has Neumann BC
with fluid entering at a certain conentration. The right boundary has a
Dirichlet BC for pressure (constant velocity in the tube) and an outflow
boundary for the transported component. If the BC for the transported component
were Dirichlet the concentration would stay at zero. With the outflow BC the
concentration may increase at the boundary dof and the component may leave the
domain through the advective flux. See also the
test/implicit/1p2coutflowproblem.
Best regards
Alex
On 07/31/2015 02:47 PM, [email protected]<mailto:[email protected]> wrote:
Dear Alex,
Thanks for your reply!
"I am not sure if I got you right, you want to have a fixed Saturation
(Dirichlet) for one phase and inject another phase?
In Dumux you can choose the equation that should be replaced by the Dirichlet
condition with the call:
setDirichlet(int pvIdx, int eqIdx)
The equation you choose cannot be assigned to a Neumann BC anymore.
The rest of the equations can be assigned as Neumann BCs.
Maybe you could list the type of BC you would like to have for each equation?"
I found a workaround to calculate the fluxes at the outlet of my system, so now
I set Dirichlet conditions at the inlet and solDependentNeumann conditions at
the outlet. This should work.
"For the box method the outflow condition uses the gradients evaluated at the
integration point of the boundary face to calculate the flux out of the domain
for the equation you choose."
If I understand correctly this means that whatever is on an outflow boundary is
allowed to flow out or into the system. So if we assume pure fickian diffusion
and the concentration in the domain is higher than on the boundary stuff will
flow out while it is vice versa if the concentration is lower. If that is the
case, what exactly is the difference to a Dirichlet boundary condition? As far
as I see, with this type of boundary condition I would keep e.g. a
concentration on the boundary constant. Am I correct?
Best regards
Georg
Von: Dumux [mailto:[email protected]] Im Auftrag von
Alexander Kissinger
Gesendet: Donnerstag, 30. Juli 2015 08:53
An: DuMuX User Forum
Betreff: Re: [DuMuX] Boundary conditions
Dear Georg,
I am not sure if I got you right, you want to have a fixed Saturation
(Dirichlet) for one phase and inject another phase?
In Dumux you can choose the equation that should be replaced by the Dirichlet
condition with the call:
setDirichlet(int pvIdx, int eqIdx)
The equation you choose cannot be assigned to a Neumann BC anymore.
The rest of the equations can be assigned as Neumann BCs.
Maybe you could list the type of BC you would like to have for each equation?
Secondly, I stumbled across the outflow boundary condition recently what is the
physical idea behind this type of boundary condition?
For the box method the outflow condition uses the gradients evaluated at the
integration point of the boundary face to calculate the flux out of the domain
for the equation you choose.
Best regards
Alex
On 29.07.2015 16:14, [email protected]<mailto:[email protected]> wrote:
Hello Dumux,
I am working with the (implicit, box) mpnc-model with a 2p5c fluidsystem and I
would like to specify the following inlet boundary conditions to my system: gas
pressure, saturation and phase composition. This can be done with a Dirichlet
condition and it works fine. But additionally, I would like to set the gas flux
into the model domain (basically the pressure gradient) which would mean
setting a Neumann boundary condition. Is there a way to do this in Dumux?
Secondly, I stumbled across the outflow boundary condition recently what is the
physical idea behind this type of boundary condition?
Thanks for your help!
Georg Futter
--------------------------
German Aerospace Center (DLR)
Institute of Engineering Thermodynamics | Computational Electrochemistry |
Pfaffenwaldring 38-40 | 70569 Stuttgart
Dipl.-Ing. Georg Futter | Ph.D. student
Telefon 0711/6862-8135 | [email protected]<mailto:[email protected]>
www.DLR.de<http://www.dlr.de/>
_______________________________________________
Dumux mailing list
[email protected]<mailto:[email protected]>
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
_______________________________________________
Dumux mailing list
[email protected]<mailto:[email protected]>
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
--
Alexander Kissinger
Institut für Wasser- und Umweltsystemmodellierung
Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
Pfaffenwaldring 61
D-70569 Stuttgart
Telefon: +49 (0) 711 685-64729
E-Mail:
[email protected]<mailto:[email protected]>
_______________________________________________
Dumux mailing list
[email protected]<mailto:[email protected]>
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
--
Alexander Kissinger
Institut für Wasser- und Umweltsystemmodellierung
Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
Pfaffenwaldring 61
D-70569 Stuttgart
Telefon: +49 (0) 711 685-64729
E-Mail:
[email protected]<mailto:[email protected]>
void boundaryTypesAtPos(BoundaryTypes &values,
const GlobalPosition &globalPos) const
{
values.setAllNeumann();
if(onInlet_(globalPos))
{
values.setAllDirichlet();
}
if(onOutlet_(globalPos))
{
values.setAllDirichlet();
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
values.setOutflow(conti0EqIdx+compIdx);
}
}
void dirichletAtPos(PrimaryVariables &values,
const GlobalPosition &globalPos) const
{
FluidState fs;
initial_(values, globalPos, fs);
}
void initial_(PrimaryVariables &values,
const GlobalPosition &globalPos,
FluidState &fs) const
{
int refPhaseIdx = nPhaseIdx;
int otherPhaseIdx = wPhaseIdx;
// set the fluid temperatures
fs.setTemperature(this->temperatureAtPos(globalPos));
// set gas saturation
fs.setSaturation(refPhaseIdx, 1.0 - swInletCathode_);
// set pressure of the gas phase
Scalar pressure = linearInterpolation_(pgInletCathode_+1e4,
pgInletCathode_, globalPos, 1);
fs.setPressure(refPhaseIdx, pressure);
// fs.setPressure(refPhaseIdx, pgInletCathode_);
// calculate the water mole fraction in the gas stream
Scalar xH2Og = H2O::vaporPressure(temperature_) /
pressure;
// Scalar xH2Og = H2O::vaporPressure(temperature_) /
// pgInletCathode_;
xH2Og *= RHCathode_;
// set the gas composition
fs.setMoleFraction(refPhaseIdx, FluidSystem::H2OIdx, xH2Og);
fs.setMoleFraction(refPhaseIdx, FluidSystem::N2Idx, 0.79 * (1.0-xH2Og));
fs.setMoleFraction(refPhaseIdx, FluidSystem::O2Idx, 0.21 * (1.0-xH2Og));
// fs.setMoleFraction(refPhaseIdx, FluidSystem::H2Idx, 0.0);
// fs.setMoleFraction(refPhaseIdx, FluidSystem::H2O2Idx, 0.0);
// set the other saturation
fs.setSaturation(otherPhaseIdx, 1.0 - fs.saturation(refPhaseIdx));
// calculate the capillary pressure
const MaterialLawParams &matParams =
this->spatialParams().materialLawParamsAtPos(globalPos);
PhaseVector pc;
MaterialLaw::capillaryPressures(pc, matParams, fs);
fs.setPressure(otherPhaseIdx,
fs.pressure(refPhaseIdx)
+ (pc[otherPhaseIdx] - pc[refPhaseIdx]));
// make the fluid state consistent with local thermodynamic
// equilibrium
typedef Dumux::ComputeFromReferencePhase<Scalar, FluidSystem>
ComputeFromReferencePhase;
ParameterCache paramCache;
ComputeFromReferencePhase::solve(fs,
paramCache,
refPhaseIdx,
/*setViscosity=*/false,
/*setEnthalpy=*/false);
///////////
// assign the primary variables
///////////
// all N component fugacities
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
values[fug0Idx + compIdx] = fs.fugacity(refPhaseIdx, compIdx);
// first M - 1 saturations
for (int phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
values[s0Idx + phaseIdx] = fs.saturation(phaseIdx);
// first pressure
values[p0Idx] = fs.pressure(/*phaseIdx=*/0);
// ionic potential
fs.setIonicPotential(electrolytePotentialCathode_);
values[ionicPotentialIdx] = fs.ionicPotential();
if (inCL_(globalPos))
{
values[Fe2PlusEqIdx] = initialFe2PlusConcentration_;
values[Fe3PlusEqIdx] = initialFe3PlusConcentration_;
}
else
{
values[Fe2PlusEqIdx] = 0.0;
values[Fe3PlusEqIdx] = 0.0;
}
}
_______________________________________________
Dumux mailing list
[email protected]
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux