From 9f0aa9f66f4428e1da204c5e02de7d2be5fff15c Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Thu, 27 Aug 2015 14:30:14 +0000
Subject: [PATCH] [2pncni] Enable the non-isothermal 2pnc model

Add required properties and their defaults.
[fix] Parameter in the ni electrochemistry
[cleanup] Adjust class names to naming conventions

Reviewed by bernd



git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@15403 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 dumux/implicit/2pnc/2pncproperties.hh         |  6 +++
 dumux/implicit/2pnc/2pncpropertydefaults.hh   | 53 +++++++++++++++++--
 dumux/implicit/2pnc/2pncvolumevariables.hh    | 16 +++---
 .../2pncmin/2pncminvolumevariables.hh         | 10 ++--
 .../electrochemistry/electrochemistry.hh      | 17 +++---
 .../electrochemistry/electrochemistryni.hh    | 12 +++--
 .../computefromreferencephase2pnc.hh          |  2 +-
 .../computefromreferencephase2pncmin.hh       |  2 +-
 .../miscible2pnccomposition.hh                |  2 +-
 9 files changed, 89 insertions(+), 31 deletions(-)

diff --git a/dumux/implicit/2pnc/2pncproperties.hh b/dumux/implicit/2pnc/2pncproperties.hh
index 185e2bb243..6af8b5c860 100644
--- a/dumux/implicit/2pnc/2pncproperties.hh
+++ b/dumux/implicit/2pnc/2pncproperties.hh
@@ -31,6 +31,7 @@
 
 #include <dumux/implicit/box/boxproperties.hh>
 #include <dumux/implicit/cellcentered/ccproperties.hh>
+#include <dumux/implicit/nonisothermal/niproperties.hh>
 
 namespace Dumux
 {
@@ -46,6 +47,11 @@ NEW_TYPE_TAG(TwoPNC);
 NEW_TYPE_TAG(BoxTwoPNC, INHERITS_FROM(BoxModel, TwoPNC));
 NEW_TYPE_TAG(CCTwoPNC, INHERITS_FROM(CCModel, TwoPNC));
 
+//! The type tag for the implicit non-isothermal two phase n component problems
+NEW_TYPE_TAG(TwoPNCNI, INHERITS_FROM(TwoPNC, NonIsothermal));
+NEW_TYPE_TAG(BoxTwoPNCNI, INHERITS_FROM(BoxModel, TwoPNCNI));
+NEW_TYPE_TAG(CCTwoPNCNI, INHERITS_FROM(CCModel, TwoPNCNI));
+
 //////////////////////////////////////////////////////////////////
 // Property tags
 //////////////////////////////////////////////////////////////////
diff --git a/dumux/implicit/2pnc/2pncpropertydefaults.hh b/dumux/implicit/2pnc/2pncpropertydefaults.hh
index a9e897073d..b2a1c42091 100644
--- a/dumux/implicit/2pnc/2pncpropertydefaults.hh
+++ b/dumux/implicit/2pnc/2pncpropertydefaults.hh
@@ -36,9 +36,10 @@
 #include "2pncproperties.hh"
 #include "2pncnewtoncontroller.hh"
 
-
+#include <dumux/implicit/nonisothermal/nipropertydefaults.hh>
 #include <dumux/implicit/common/implicitdarcyfluxvariables.hh>
 #include <dumux/material/spatialparams/implicitspatialparams.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh>
 
 namespace Dumux
 {
@@ -125,10 +126,8 @@ public:
     typedef typename MaterialLaw::Params type;
 };
 
-//! Use the 2pnc local residual operator
-SET_TYPE_PROP(TwoPNC,
-              LocalResidual,
-              TwoPNCLocalResidual<TypeTag>);
+//! Use the 2pnc local residual
+SET_TYPE_PROP(TwoPNC, LocalResidual, TwoPNCLocalResidual<TypeTag>);
 
 //! Use the 2pnc newton controller
 SET_TYPE_PROP(TwoPNC, NewtonController, TwoPNCNewtonController<TypeTag>);
@@ -162,6 +161,50 @@ SET_BOOL_PROP(TwoPNC, ProblemEnableGravity, true);
 
 //! Disable velocity output by default
 SET_BOOL_PROP(TwoPNC, VtkAddVelocity, false);
+
+//! Somerton is used as default model to compute the effective thermal heat conductivity
+SET_PROP(NonIsothermal, ThermalConductivityModel)
+{
+private:
+    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
+    typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
+public:
+    typedef ThermalConductivitySomerton<Scalar, Indices> type;
+};
+
+//! temperature is already written by the isothermal model
+SET_BOOL_PROP(TwoPNCNI, NiOutputLevel, 0);
+
+//////////////////////////////////////////////////////////////////
+// Property values for isothermal model required for the general non-isothermal model
+//////////////////////////////////////////////////////////////////
+
+// set isothermal Model
+SET_TYPE_PROP(TwoPNCNI, IsothermalModel, TwoPNCModel<TypeTag>);
+
+// set isothermal FluxVariables
+SET_TYPE_PROP(TwoPNCNI, IsothermalFluxVariables, TwoPNCFluxVariables<TypeTag>);
+
+//set isothermal VolumeVariables
+SET_TYPE_PROP(TwoPNCNI, IsothermalVolumeVariables, TwoPNCVolumeVariables<TypeTag>);
+
+//set isothermal LocalResidual
+SET_TYPE_PROP(TwoPNCNI, IsothermalLocalResidual, TwoPNCLocalResidual<TypeTag>);
+
+//set isothermal Indices
+SET_TYPE_PROP(TwoPNCNI, IsothermalIndices, TwoPNCIndices<TypeTag, /*PVOffset=*/0>);
+
+//set isothermal NumEq
+SET_PROP(TwoPNCNI, IsothermalNumEq)
+{
+private:
+    typedef typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)) FluidSystem;
+
+public:
+    static const int value = FluidSystem::numComponents;
+};
+
+
 }
 
 }
diff --git a/dumux/implicit/2pnc/2pncvolumevariables.hh b/dumux/implicit/2pnc/2pncvolumevariables.hh
index 54cd3f1cf9..6e68973655 100644
--- a/dumux/implicit/2pnc/2pncvolumevariables.hh
+++ b/dumux/implicit/2pnc/2pncvolumevariables.hh
@@ -97,8 +97,8 @@ class TwoPNCVolumeVariables : public ImplicitVolumeVariables<TypeTag>
 
     typedef typename GridView::template Codim<0>::Entity Element;
     typedef typename Grid::ctype CoordScalar;
-    typedef Dumux::miscible2pncComposition<Scalar, FluidSystem> miscible2pncComposition;
-    typedef Dumux::computeFromReferencePhase2pnc<Scalar, FluidSystem> computeFromReferencePhase2pnc;
+    typedef Dumux::Miscible2pNCComposition<Scalar, FluidSystem> Miscible2pNCComposition;
+    typedef Dumux::ComputeFromReferencePhase2pNC<Scalar, FluidSystem> ComputeFromReferencePhase2pNC;
 
     enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) };
     enum { dofCodim = isBox ? dim : 0 };
@@ -258,13 +258,13 @@ public:
             // constraint solver
 
             // set the known mole fractions in the fluidState so that they
-            // can be used by the miscible2pncComposition constraint solver
+            // can be used by the Miscible2pNCComposition constraint solver
             for (int compIdx=numMajorComponents; compIdx<numComponents; ++compIdx)
             {
                 fluidState.setMoleFraction(wPhaseIdx, compIdx, primaryVariables[compIdx]);
             }
 
-            miscible2pncComposition::solve(fluidState,
+            Miscible2pNCComposition::solve(fluidState,
                         paramCache,
                         wPhaseIdx,	//known phaseIdx
                         /*setViscosity=*/true,
@@ -296,8 +296,8 @@ public:
 
             // calculate the composition of the remaining phases (as
             // well as the densities of all phases). this is the job
-            // of the "computeFromReferencePhase2pnc" constraint solver
-                computeFromReferencePhase2pnc::solve(fluidState,
+            // of the "ComputeFromReferencePhase2pNC" constraint solver
+                ComputeFromReferencePhase2pNC::solve(fluidState,
                                                 paramCache,
                                                 nPhaseIdx,
                                                 /*setViscosity=*/true,
@@ -332,8 +332,8 @@ public:
 
             // calculate the composition of the remaining phases (as
             // well as the densities of all phases). this is the job
-            // of the "computeFromReferencePhase2pnc" constraint solver
-            computeFromReferencePhase2pnc::solve(fluidState,
+            // of the "ComputeFromReferencePhase2pNC" constraint solver
+            ComputeFromReferencePhase2pNC::solve(fluidState,
                                                 paramCache,
                                                 wPhaseIdx,
                                                 /*setViscosity=*/true,
diff --git a/dumux/implicit/2pncmin/2pncminvolumevariables.hh b/dumux/implicit/2pncmin/2pncminvolumevariables.hh
index fea975767b..bc2671b106 100644
--- a/dumux/implicit/2pncmin/2pncminvolumevariables.hh
+++ b/dumux/implicit/2pncmin/2pncminvolumevariables.hh
@@ -101,8 +101,8 @@ class TwoPNCMinVolumeVariables : public TwoPNCVolumeVariables<TypeTag>
     typedef typename GridView::template Codim<0>::Entity Element;
     typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
     typedef typename Grid::ctype CoordScalar;
-    typedef Dumux::miscible2pncComposition<Scalar, FluidSystem> miscible2pncComposition;
-    typedef Dumux::computeFromReferencePhase2pncmin<Scalar, FluidSystem> computeFromReferencePhase2pncmin;
+    typedef Dumux::Miscible2pNCComposition<Scalar, FluidSystem> Miscible2pNCComposition;
+    typedef Dumux::ComputeFromReferencePhase2pNCMin<Scalar, FluidSystem> ComputeFromReferencePhase2pNCMin;
 
     enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) };
     enum { dofCodim = isBox ? dim : 0 };
@@ -290,7 +290,7 @@ public:
             	fluidState.setMoleFraction(wPhaseIdx, compIdx, priVars[compIdx]);
             }
 
-            miscible2pncComposition::solve(fluidState,
+            Miscible2pNCComposition::solve(fluidState,
                                             paramCache,
                                             wPhaseIdx,	//known phaseIdx
                                             /*setViscosity=*/true,
@@ -339,7 +339,7 @@ public:
             // calculate the composition of the remaining phases (as
             // well as the densities of all phases). this is the job
             // of the "ComputeFromReferencePhase2pNc" constraint solver
-            computeFromReferencePhase2pncmin::solve(fluidState,
+            ComputeFromReferencePhase2pNCMin::solve(fluidState,
                                                     paramCache,
                                                     nPhaseIdx,
                                                     nPhaseOnly,
@@ -376,7 +376,7 @@ public:
 //             calculate the composition of the remaining phases (as
 //             well as the densities of all phases). this is the job
 //             of the "ComputeFromReferencePhase2pNc" constraint solver
-            computeFromReferencePhase2pncmin::solve(fluidState,
+            ComputeFromReferencePhase2pNCMin::solve(fluidState,
                                                     paramCache,
                                                     wPhaseIdx,
                                                     wPhaseOnly,
diff --git a/dumux/material/chemistry/electrochemistry/electrochemistry.hh b/dumux/material/chemistry/electrochemistry/electrochemistry.hh
index db1d597d97..840d5032d4 100644
--- a/dumux/material/chemistry/electrochemistry/electrochemistry.hh
+++ b/dumux/material/chemistry/electrochemistry/electrochemistry.hh
@@ -65,23 +65,26 @@ class ElectroChemistry
     enum {
         //indices of the phases
         wPhaseIdx = Indices::wPhaseIdx,
-        nPhaseIdx = Indices::nPhaseIdx,
-
+        nPhaseIdx = Indices::nPhaseIdx
+    };
+    enum {
         //indices of the components
         wCompIdx = FluidSystem::wCompIdx, //major component of the liquid phase
         nCompIdx = FluidSystem::nCompIdx, //major component of the gas phase
-        O2Idx = wCompIdx + 2,
-
+        O2Idx = wCompIdx + 2
+    };
+    enum {
         //indices of the primary variables
         pressureIdx = Indices::pressureIdx, //gas-phase pressure
         switchIdx = Indices::switchIdx, //liquid saturation or mole fraction
-        temperatureIdx = FluidSystem::numComponents, //temperature
-
+        temperatureIdx = FluidSystem::numComponents //temperature
+    };
+    enum {
         //equation indices
         conti0EqIdx = Indices::conti0EqIdx,
         contiH2OEqIdx = conti0EqIdx + wCompIdx,
         contiO2EqIdx = conti0EqIdx + wCompIdx + 2,
-        energyEqIdx = FluidSystem::numComponents, //energy equation
+        energyEqIdx = FluidSystem::numComponents //energy equation
     };
 
 public:
diff --git a/dumux/material/chemistry/electrochemistry/electrochemistryni.hh b/dumux/material/chemistry/electrochemistry/electrochemistryni.hh
index 41ebfd92ca..ce2395948c 100644
--- a/dumux/material/chemistry/electrochemistry/electrochemistryni.hh
+++ b/dumux/material/chemistry/electrochemistry/electrochemistryni.hh
@@ -50,13 +50,18 @@ class ElectroChemistryNI : public ElectroChemistry<TypeTag, electroChemistryMode
     typedef Dumux::Constants<Scalar> Constant;
 
     typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
-
+    enum {
+        //indices of the components
+        wCompIdx = FluidSystem::wCompIdx, //major component of the liquid phase
+        nCompIdx = FluidSystem::nCompIdx, //major component of the gas phase
+        O2Idx = wCompIdx + 2
+    };
     enum { //equation indices
             conti0EqIdx = Indices::conti0EqIdx,
             contiH2OEqIdx = conti0EqIdx + wCompIdx,
             contiO2EqIdx = conti0EqIdx + wCompIdx + 2,
             energyEqIdx = FluidSystem::numComponents, //energy equation
-        };
+    };
 
 public:
     /*!
@@ -76,12 +81,13 @@ public:
         static Scalar gridYMax = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.UpperRightY);
         static Scalar nCellsY = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.NumberOfCellsY);
         static Scalar thermoneutralVoltage = GET_RUNTIME_PARAM(TypeTag, Scalar, ElectroChemistry.ThermoneutralVoltage);
+        static Scalar cellVoltage = GET_RUNTIME_PARAM(TypeTag, Scalar, ElectroChemistry.CellVoltage);
 
         //initialise current density
         Scalar currentDensity = 0.0;
 
         //call internal method to calculate the current density
-        currentDensity = this->calculateCurrentDensity_(volVars, maxIter);
+        currentDensity = ParentType::calculateCurrentDensity_(volVars, maxIter);
 
         //correction to account for actually relevant reaction area
         //current density has to be devided by the half length of the box
diff --git a/dumux/material/constraintsolvers/computefromreferencephase2pnc.hh b/dumux/material/constraintsolvers/computefromreferencephase2pnc.hh
index 0f4d42e28d..340ac18c8e 100644
--- a/dumux/material/constraintsolvers/computefromreferencephase2pnc.hh
+++ b/dumux/material/constraintsolvers/computefromreferencephase2pnc.hh
@@ -65,7 +65,7 @@ namespace Dumux {
  * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases
  */
 template <class Scalar, class FluidSystem>
-class computeFromReferencePhase2pnc
+class ComputeFromReferencePhase2pNC
 {
     enum { numPhases = FluidSystem::numPhases };
     enum { numComponents = FluidSystem::numComponents };
diff --git a/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh b/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh
index b7037a880f..3b0f150f3b 100644
--- a/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh
+++ b/dumux/material/constraintsolvers/computefromreferencephase2pncmin.hh
@@ -65,7 +65,7 @@ namespace Dumux {
  * - if the setEnthalpy parameter is true, also specific enthalpies and internal energies of *all* phases
  */
 template <class Scalar, class FluidSystem>
-class computeFromReferencePhase2pncmin
+class ComputeFromReferencePhase2pNCMin
 {
     enum { numPhases = FluidSystem::numPhases };
     enum { numComponents = FluidSystem::numComponents };
diff --git a/dumux/material/constraintsolvers/miscible2pnccomposition.hh b/dumux/material/constraintsolvers/miscible2pnccomposition.hh
index 068eb12f68..0dbca54ee9 100644
--- a/dumux/material/constraintsolvers/miscible2pnccomposition.hh
+++ b/dumux/material/constraintsolvers/miscible2pnccomposition.hh
@@ -57,7 +57,7 @@ namespace Dumux {
  * - if the setInternalEnergy parameter is true, also specific enthalpies and internal energies of *all* phases
  */
 template <class Scalar, class FluidSystem>
-class miscible2pncComposition
+class Miscible2pNCComposition
 {
     static const int numPhases = FluidSystem::numPhases;
     static const int numComponents = FluidSystem::numComponents;
-- 
GitLab