From 25b70e8fbf9a858362e6832681e9bca4abdbeacf Mon Sep 17 00:00:00 2001
From: Shuang Chen <gechenshuang88@gmail.com>
Date: Wed, 23 Sep 2020 10:36:36 +0200
Subject: [PATCH] [BHE] add a new flow and temperature curve control condition

fixed comments and the description of the user guide

add the tag-documentation files for the new case
---
 .../c_TemperatureCurveFlowCurve.md               |  1 +
 .../t_flow_rate_curve.md                         |  1 +
 .../t_temperature_curve.md                       |  1 +
 .../BHE/CreateFlowAndTemperatureControl.cpp      | 16 ++++++++++++++++
 .../BHE/FlowAndTemperatureControl.h              | 13 +++++++++++++
 .../Heat_Transport_BHE.md                        |  2 ++
 6 files changed, 34 insertions(+)
 create mode 100644 Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/c_TemperatureCurveFlowCurve.md
 create mode 100644 Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_flow_rate_curve.md
 create mode 100644 Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_temperature_curve.md

diff --git a/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/c_TemperatureCurveFlowCurve.md b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/c_TemperatureCurveFlowCurve.md
new file mode 100644
index 00000000000..b1b8343fb4d
--- /dev/null
+++ b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/c_TemperatureCurveFlowCurve.md
@@ -0,0 +1 @@
+This is another type of controlling temperature difference with specific inflow temperature curve and flow rate curve.
diff --git a/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_flow_rate_curve.md b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_flow_rate_curve.md
new file mode 100644
index 00000000000..aaa7cb2dc90
--- /dev/null
+++ b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_flow_rate_curve.md
@@ -0,0 +1 @@
+It means the flow rate in the pipes varying with time. the flow rate curve should be presented and set as input data. The Flow rate in the curve needs to be offered by using m3/s as its unit.
diff --git a/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_temperature_curve.md b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_temperature_curve.md
new file mode 100644
index 00000000000..6481161a9fe
--- /dev/null
+++ b/Documentation/ProjectFile/prj/processes/process/HEAT_TRANSPORT_BHE/borehole_heat_exchangers/borehole_heat_exchanger/flow_and_temperature_control/TemperatureCurveFlowCurve/t_temperature_curve.md
@@ -0,0 +1 @@
+It means the inflow temperature curve varying with time.
diff --git a/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp b/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp
index 888cc97e53d..9b33122341e 100644
--- a/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp
+++ b/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp
@@ -44,6 +44,22 @@ FlowAndTemperatureControl createFlowAndTemperatureControl(
 
         return TemperatureCurveConstantFlow{flow_rate, temperature_curve};
     }
+    if (type == "TemperatureCurveFlowCurve")
+    {
+        auto const& flow_rate_curve = *BaseLib::getOrError(
+            curves,
+            //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__TemperatureCurveFlowCurve__flow_rate_curve}
+            config.getConfigParameter<std::string>("flow_rate_curve"),
+            "Required flow curve not found.");
+
+        auto const& temperature_curve = *BaseLib::getOrError(
+            curves,
+            //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__TemperatureCurveFlowCurve__temperature_curve}
+            config.getConfigParameter<std::string>("temperature_curve"),
+            "Required temperature curve not found.");
+
+        return TemperatureCurveFlowCurve{flow_rate_curve, temperature_curve};
+    }
     if (type == "FixedPowerConstantFlow")
     {
         //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__FixedPowerConstantFlow__power}
diff --git a/ProcessLib/HeatTransportBHE/BHE/FlowAndTemperatureControl.h b/ProcessLib/HeatTransportBHE/BHE/FlowAndTemperatureControl.h
index a718751a973..6c83f56e644 100644
--- a/ProcessLib/HeatTransportBHE/BHE/FlowAndTemperatureControl.h
+++ b/ProcessLib/HeatTransportBHE/BHE/FlowAndTemperatureControl.h
@@ -37,6 +37,18 @@ struct TemperatureCurveConstantFlow
     MathLib::PiecewiseLinearInterpolation const& temperature_curve;
 };
 
+struct TemperatureCurveFlowCurve
+{
+    FlowAndTemperature operator()(double const /*T_out*/,
+                                  double const time) const
+    {
+        return {flow_rate_curve.getValue(time),
+                temperature_curve.getValue(time)};
+    }
+    MathLib::PiecewiseLinearInterpolation const& flow_rate_curve;
+    MathLib::PiecewiseLinearInterpolation const& temperature_curve;
+};
+
 struct FixedPowerConstantFlow
 {
     FlowAndTemperature operator()(double const T_out,
@@ -106,6 +118,7 @@ struct BuildingPowerCurveConstantFlow
 };
 
 using FlowAndTemperatureControl = std::variant<TemperatureCurveConstantFlow,
+                                               TemperatureCurveFlowCurve,
                                                FixedPowerConstantFlow,
                                                FixedPowerFlowCurve,
                                                PowerCurveConstantFlow,
diff --git a/web/content/docs/userguide/process-dependent-configuration/Heat_Transport_BHE.md b/web/content/docs/userguide/process-dependent-configuration/Heat_Transport_BHE.md
index d35720e5fe9..63b0c935ddd 100644
--- a/web/content/docs/userguide/process-dependent-configuration/Heat_Transport_BHE.md
+++ b/web/content/docs/userguide/process-dependent-configuration/Heat_Transport_BHE.md
@@ -121,6 +121,8 @@ Four type of flow and temperature control patterns are provided in OGS.
   The key word < flow_rate > applies here, along with the curve defined in the < curves >.
 * TemperatureCurveConstantFlow:\
   It means BHE has a constant < flow_rate > while the inflow temperature following the values defined in the < curves >.
+* TemperatureCurveFlowCurve:\
+  It means both the BHE inflow rate and temperature values are following the corresponding curves.
 
 The unit of < power > is in $\mathrm{W}$ and < flow_rate > is in $\mathrm{m^{3}/s}$. For heating applications, thermal energy is extracted from the subsurface, then a negative power value should be given. It is vice versa for cooling applications.
 
-- 
GitLab