make the CO2 injection problem usable with AD

and use automatic differentiation for the simulator of the non-isothermal
immiscible co2 injection problem.
This commit is contained in:
Andreas Lauser 2015-05-21 16:18:40 +02:00
parent 2cef2a54f2
commit 528c2a8350
2 changed files with 13 additions and 11 deletions

View File

@ -37,6 +37,9 @@ SET_TAG_PROP(Co2InjectionImmiscibleNiEcfvProblem, SpatialDiscretizationSplice,
EcfvDiscretization); EcfvDiscretization);
SET_BOOL_PROP(Co2InjectionImmiscibleNiEcfvProblem, EnableEnergy, true); SET_BOOL_PROP(Co2InjectionImmiscibleNiEcfvProblem, EnableEnergy, true);
//! Use automatic differentiation to linearize the system of PDEs
SET_TAG_PROP(Co2InjectionImmiscibleNiEcfvProblem, LocalLinearizerSplice, AutoDiffLocalLinearizer);
}} }}
//////////////////////// ////////////////////////

View File

@ -90,11 +90,9 @@ private:
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef Ewoms::Co2Injection::CO2Tables CO2Tables; typedef Ewoms::Co2Injection::CO2Tables CO2Tables;
static const bool useComplexRelations = false;
public: public:
typedef Opm::FluidSystems::BrineCO2<Scalar, CO2Tables> type; typedef Opm::FluidSystems::BrineCO2<Scalar, CO2Tables> type;
// typedef Opm::FluidSystems::H2ON2<Scalar, useComplexRelations> type; //typedef Opm::FluidSystems::H2ON2<Scalar, /*useComplexRelations=*/false> type;
}; };
// Set the material Law // Set the material Law
@ -108,8 +106,7 @@ private:
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef Opm::TwoPhaseMaterialTraits<Scalar, typedef Opm::TwoPhaseMaterialTraits<Scalar,
/*wettingPhaseIdx=*/FluidSystem::liquidPhaseIdx, /*wettingPhaseIdx=*/FluidSystem::liquidPhaseIdx,
/*nonWettingPhaseIdx=*/FluidSystem::gasPhaseIdx> /*nonWettingPhaseIdx=*/FluidSystem::gasPhaseIdx> Traits;
Traits;
// define the material law which is parameterized by effective // define the material law which is parameterized by effective
// saturations // saturations
@ -195,8 +192,9 @@ class Co2InjectionProblem : public GET_PROP_TYPE(TypeTag, BaseProblem)
{ {
typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType; typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem; typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
enum { dim = GridView::dimension }; enum { dim = GridView::dimension };
@ -222,6 +220,7 @@ class Co2InjectionProblem : public GET_PROP_TYPE(TypeTag, BaseProblem)
typedef typename GET_PROP_TYPE(TypeTag, HeatConductionLaw) HeatConductionLaw; typedef typename GET_PROP_TYPE(TypeTag, HeatConductionLaw) HeatConductionLaw;
typedef typename HeatConductionLaw::Params HeatConductionLawParams; typedef typename HeatConductionLaw::Params HeatConductionLawParams;
typedef Opm::MathToolbox<Evaluation> Toolbox;
typedef typename GridView::ctype CoordScalar; typedef typename GridView::ctype CoordScalar;
typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition; typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition;
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix; typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
@ -476,15 +475,15 @@ public:
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs; Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
fs.setSaturation(gasPhaseIdx, 1.0); fs.setSaturation(gasPhaseIdx, 1.0);
fs.setPressure(gasPhaseIdx, const auto& pg =
context.intensiveQuantities(spaceIdx, timeIdx).fluidState().pressure( context.intensiveQuantities(spaceIdx, timeIdx).fluidState().pressure(gasPhaseIdx);
gasPhaseIdx)); fs.setPressure(gasPhaseIdx, Toolbox::value(pg));
fs.setTemperature(temperature(context, spaceIdx, timeIdx)); fs.setTemperature(temperature(context, spaceIdx, timeIdx));
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::ParameterCache paramCache;
paramCache.updatePhase(fs, gasPhaseIdx); paramCache.updatePhase(fs, gasPhaseIdx);
Scalar h = FluidSystem::enthalpy(fs, paramCache, gasPhaseIdx); Scalar h = FluidSystem::enthalpy(fs, paramCache, gasPhaseIdx);
// impose an forced inflow boundary condition // impose an forced inflow boundary condition for pure CO2
values.setMassRate(massRate); values.setMassRate(massRate);
values.setEnthalpyRate(massRate[contiCO2EqIdx] * h); values.setEnthalpyRate(massRate[contiCO2EqIdx] * h);
} }
@ -550,7 +549,7 @@ private:
////// //////
// set pressures // set pressures
////// //////
Scalar densityL = FluidSystem::Brine::liquidDensity(temperature_, 1e5); Scalar densityL = FluidSystem::Brine::liquidDensity(temperature_, Scalar(1e5));
Scalar depth = maxDepth_ - pos[dim - 1]; Scalar depth = maxDepth_ - pos[dim - 1];
Scalar pl = 1e5 - densityL * this->gravity()[dim - 1] * depth; Scalar pl = 1e5 - densityL * this->gravity()[dim - 1] * depth;