From 3efc08c72c2883b22903ffcdbe9e0de8f480e448 Mon Sep 17 00:00:00 2001 From: IvBu <ivan.buntic@iws.uni-stuttgart.de> Date: Tue, 16 Jul 2024 17:17:28 +0200 Subject: [PATCH] [basic] Refactor solution and README. --- exercises/exercise-basic/README.md | 8 +++--- .../exercise-basic/injection2pniproblem.hh | 25 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/exercises/exercise-basic/README.md b/exercises/exercise-basic/README.md index 839644a0..ecd78ecf 100644 --- a/exercises/exercise-basic/README.md +++ b/exercises/exercise-basic/README.md @@ -70,7 +70,7 @@ dumux_add_test(NAME exercise_basic_2pni SOURCES 2pnimain.cc) ``` -* Test that everything compiles without error +* In the respective build-cmake folder, test that everything compiles without error ```bash make # should rerun cmake @@ -91,12 +91,12 @@ Look for comments containing * The following set-up should be realized: - __Boundary conditions:__ Dirichlet conditions at the left boundary. For the primary variable __temperature__ use a varying temperature of <br/> + __Initial conditions:__ For the primary variable __temperature__ use a varying temperature of <br/> $`\displaystyle T(y) = 283~\text{K} + 0.03~\frac{\text{K}}{\text{m}} \cdot \left( d_\text{aquifer} - y \right)`$, <br/> with the aquifer depth -$\displaystyle d_\text{aquifer}=2700~\text{m}$. Add an energy flux at the injection point of N$_2$. Assign Neumann no-flow for the energy balance to the rest of the boundaries. +$\displaystyle d_\text{aquifer}=2700~\text{m}$. Additionally, add a subdomain (20 < x < 30, 5 < y < 35), where you assign a constant initial temperature of 380 K. - __Initial conditions:__ The same temperature gradient as in the boundary conditions with an exception in the subdomain (20 < x < 30, 5 < y < 35), where you assign a constant initial temperature of 380 K. + __Boundary conditions:__ Dirichlet boundary conditions at the left boundary with the same temperature gradient as in the initial conditions. For the Neumann conditions, assign an energy flux at the injection point of N$_2$ and no-flow conditions for the energy balance to the rest of the boundaries. <img src="https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/master/exercises/extradoc/exercise1_nonisothermal.png" width="800"> diff --git a/exercises/solution/exercise-basic/injection2pniproblem.hh b/exercises/solution/exercise-basic/injection2pniproblem.hh index 01734701..7cb3c10b 100644 --- a/exercises/solution/exercise-basic/injection2pniproblem.hh +++ b/exercises/solution/exercise-basic/injection2pniproblem.hh @@ -144,15 +144,18 @@ public: // if we are inside the injection zone set inflow Neumann boundary conditions if (injectionActive() && onInjectionBoundary(globalPos)) { - - // inject nitrogen. negative values mean injection - // units kg/(s*m^2) - values[Indices::conti0EqIdx + FluidSystem::N2Idx] = -1e-4; + const Scalar injectionRate = -1e-4; + + // inject nitrogen. Negative values mean injection + // unit: kg/(s*m^2) + values[Indices::conti0EqIdx + FluidSystem::N2Idx] = injectionRate; values[Indices::conti0EqIdx + FluidSystem::H2OIdx] = 0.0; // energy fluxes are always mass specific - //units W/(m^2) - values[Indices::energyEqIdx] = -1e-4 /*kg/(m^2 s)*/ *N2::gasEnthalpy(injectionTemperature(), 1e5 /*Pa*/)/*J/kg*/; + // unit: W/(m^2) + const Scalar temperatureAtInjection = initialAtPos(globalPos)[Indices::temperatureIdx];/*K*/ + const Scalar pressureAtInjection = initialAtPos(globalPos)[Indices::pressureIdx];/*Pa*/ + values[Indices::energyEqIdx] = injectionRate /*kg/(m^2 s)*/ *N2::gasEnthalpy(temperatureAtInjection, pressureAtInjection)/*J/kg*/; } return values; @@ -190,7 +193,7 @@ public: values[Indices::temperatureIdx] = 283.0 + (aquiferDepth_ - globalPos[1])*0.03; if (globalPos[0] > 20 - eps_ && globalPos[0] < 30 + eps_ && globalPos[1] > 5 - eps_ && globalPos[1] < 35 + eps_) - values[Indices::temperatureIdx] = injectionTemperature(); + values[Indices::temperatureIdx] = 380.0; return values; } @@ -198,7 +201,7 @@ public: //! Set the time for the time dependent boundary conditions (called from main) void setTime(Scalar time) { time_ = time; } - + //! Return true if the injection is currently active bool injectionActive() const { return time_ < injectionDuration_; } @@ -211,12 +214,6 @@ public: && globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; } - //! Set injection temperature for the domain - Scalar injectionTemperature() const - { - return 380.0; - } - private: static constexpr Scalar eps_ = 1e-6; std::string name_; //! Problem name -- GitLab