From 6f2f0c47c12528dfa23a938f0ba77c4933c4a311 Mon Sep 17 00:00:00 2001
From: Dominik Riesterer <thedom.89@googlemail.com>
Date: Fri, 20 Sep 2013 14:23:12 +0000
Subject: [PATCH] The model can be used with either mole or mass fractions. The
 property useMoles has to be set in the problem file and the boundary
 conditions have to be choosen accordingly.

In order to be consistent with the multicomponent models (3p3c,
3p3cni,...) the model uses MOLE fractions by default now.

The documentation is changed and extended accordingly.

reviewd by kathinka


git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@11525 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 dumux/implicit/1p2c/1p2clocalresidual.hh    | 12 ++++++------
 dumux/implicit/1p2c/1p2cmodel.hh            |  2 ++
 dumux/implicit/1p2c/1p2cpropertydefaults.hh |  2 +-
 test/implicit/1p2c/1p2coutflowproblem.hh    | 19 ++++++++++++++++++-
 4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/dumux/implicit/1p2c/1p2clocalresidual.hh b/dumux/implicit/1p2c/1p2clocalresidual.hh
index 4cf0c15b88..69a38de0b4 100644
--- a/dumux/implicit/1p2c/1p2clocalresidual.hh
+++ b/dumux/implicit/1p2c/1p2clocalresidual.hh
@@ -105,7 +105,7 @@ public:
         const VolumeVariables &volVars = elemVolVars[scvIdx];
 
         storage = 0;
-        if(!useMoles)
+        if(!useMoles) //mass-fraction formulation
         {
             // storage term of continuity equation - massfractions
             storage[conti0EqIdx] +=
@@ -114,7 +114,7 @@ public:
             storage[transportEqIdx] +=
                 volVars.fluidState().density(phaseIdx) * volVars.fluidState().massFraction(phaseIdx, transportCompIdx) * volVars.porosity();
         }
-        else
+        else //mole-fraction formulation
         {
             // storage term of continuity equation- molefractions
             //careful: molarDensity changes with moleFrac!
@@ -170,7 +170,7 @@ public:
         const VolumeVariables &dn =
             this->curVolVars_(fluxVars.downstreamIdx());
 
-        if(!useMoles)
+        if(!useMoles) //mass-fraction formulation
         {
             // total mass flux - massfraction
             //KmvpNormal is the Darcy velocity multiplied with the normal vector, calculated in 1p2cfluxvariables.hh
@@ -187,7 +187,7 @@ public:
                  +
                  (1 - upwindWeight_)*dn.fluidState().density(phaseIdx)*dn.fluidState().massFraction(phaseIdx, transportCompIdx)/dn.viscosity());
         }
-        else
+        else //mole-fraction formulation
         {
             // total mass flux - molefraction
             //KmvpNormal is the Darcy velocity multiplied with the normal vector, calculated in 1p2cfluxvariables.hh
@@ -219,7 +219,7 @@ public:
         Scalar tmp(0);
 
         // diffusive flux of second component
-        if(!useMoles)
+        if(!useMoles) //mass-fraction formulation
         {
             // diffusive flux of the second component - massfraction
             tmp = -(fluxVars.moleFractionGrad(transportCompIdx)*fluxVars.face().normal);
@@ -234,7 +234,7 @@ public:
             // convert it to a mass flux and add it
             flux[transportEqIdx] += tmp * FluidSystem::molarMass(transportCompIdx);
         }
-        else
+        else //mole-fraction formulation
         {
             // diffusive flux of the second component - molefraction
             tmp = -(fluxVars.moleFractionGrad(transportCompIdx)*fluxVars.face().normal);
diff --git a/dumux/implicit/1p2c/1p2cmodel.hh b/dumux/implicit/1p2c/1p2cmodel.hh
index a2ef602e9b..3aab3ba736 100644
--- a/dumux/implicit/1p2c/1p2cmodel.hh
+++ b/dumux/implicit/1p2c/1p2cmodel.hh
@@ -64,6 +64,8 @@ namespace Dumux
  * All equations are discretized using a vertex-centered finite volume (box)
  * or cell-centered finite volume scheme as spatial
  * and the implicit Euler method as time discretization.
+ * The model is able to use either mole or mass fractions. The property useMoles can be set to either true or false in the
+ * problem file. Make sure that the according units are used in the problem setup. useMoles is set to true by default.
  *
  * The primary variables are the pressure \f$p\f$ and the mole or mass fraction of dissolved component \f$x\f$.
  */
diff --git a/dumux/implicit/1p2c/1p2cpropertydefaults.hh b/dumux/implicit/1p2c/1p2cpropertydefaults.hh
index ec568d8ced..4df765a1b6 100644
--- a/dumux/implicit/1p2c/1p2cpropertydefaults.hh
+++ b/dumux/implicit/1p2c/1p2cpropertydefaults.hh
@@ -53,7 +53,7 @@ SET_INT_PROP(OnePTwoC, NumEq, 2); //!< set the number of equations to 2
 SET_INT_PROP(OnePTwoC, NumPhases, 1); //!< The number of phases in the 1p2c model is 1
 SET_INT_PROP(OnePTwoC, NumComponents, 2); //!< The number of components in the 1p2c model is 2
 SET_SCALAR_PROP(OnePTwoC, Scaling, 1); //!< Scaling of the model is set to 1 by default
-SET_BOOL_PROP(OnePTwoC, UseMoles, false); //!< Define that mass fractions are used in the balance equations
+SET_BOOL_PROP(OnePTwoC, UseMoles, true); //!< Define that mole fractions are used in the balance equations
 
 //! Use the 1p2c local residual function for the 1p2c model
 SET_TYPE_PROP(OnePTwoC, LocalResidual, OnePTwoCLocalResidual<TypeTag>);
diff --git a/test/implicit/1p2c/1p2coutflowproblem.hh b/test/implicit/1p2c/1p2coutflowproblem.hh
index cf7b25ac1a..77664eb8e1 100644
--- a/test/implicit/1p2c/1p2coutflowproblem.hh
+++ b/test/implicit/1p2c/1p2coutflowproblem.hh
@@ -79,7 +79,7 @@ SET_TYPE_PROP(OnePTwoCOutflowProblem,
               Dumux::OnePTwoCOutflowSpatialParams<TypeTag>);
 
 // Define whether mole(true) or mass (false) fractions are used
-SET_BOOL_PROP(OnePTwoCOutflowProblem, UseMoles, false);
+SET_BOOL_PROP(OnePTwoCOutflowProblem, UseMoles, true);
 
 // Enable velocity output
 SET_BOOL_PROP(OnePTwoCOutflowProblem, VtkAddVelocity, true);
@@ -108,6 +108,9 @@ SET_BOOL_PROP(OnePTwoCOutflowProblem, ProblemEnableGravity, false);
  * and leaves the domain at the right boundary
  * where an outflow boundary condition is applied.
  * 
+ * The model is able to use either mole or mass fractions. The property useMoles can be set to either true or false in the
+ * problem file. Make sure that the according units are used in the problem setup. The default setting for useMoles is true.
+ *
  * This problem uses the \ref OnePTwoCBoxModel model.
  *
  * To run the simulation execute the following line in shell:
@@ -161,6 +164,16 @@ public:
                                              std::string, 
                                              Problem, 
                                              Name);
+
+        //stateing in the console whether mole or mass fractions are used
+        if(!useMoles)
+        {
+        	std::cout<<"problem uses mass-fractions"<<std::endl;
+        }
+        else
+        {
+        	std::cout<<"problem uses mole-fractions"<<std::endl;
+        }
     }
 
     /*!
@@ -242,6 +255,8 @@ public:
      * For this method, the \a priVars parameter stores the mass flux
      * in normal direction of each component. Negative values mean
      * influx.
+     *
+     * The units must be according to either using mole or mass fractions. (mole/(m^2*s) or kg/(m^2*s))
      */
     void neumann(PrimaryVariables &priVars,
                  const Element &element,
@@ -268,6 +283,8 @@ public:
      * of a component is generated or annihilate per volume
      * unit. Positive values mean that mass is created, negative ones
      * mean that it vanishes.
+     *
+     * The units must be according to either using mole or mass fractions. (mole/(m^3*s) or kg/(m^3*s))
      */
     void sourceAtPos(PrimaryVariables &priVars,
                      const GlobalPosition &globalPos) const
-- 
GitLab