00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OPM_STANDARDWELL_HEADER_INCLUDED
00024 #define OPM_STANDARDWELL_HEADER_INCLUDED
00025
00026
00027 #include <opm/autodiff/WellInterface.hpp>
00028
00029 namespace Opm
00030 {
00031
00032 template<typename TypeTag>
00033 class StandardWell: public WellInterface<TypeTag>
00034 {
00035
00036 public:
00037 typedef WellInterface<TypeTag> Base;
00038
00039
00040
00041 using typename Base::Simulator;
00042 using typename Base::WellState;
00043 using typename Base::IntensiveQuantities;
00044 using typename Base::FluidSystem;
00045 using typename Base::MaterialLaw;
00046 using typename Base::ModelParameters;
00047 using typename Base::BlackoilIndices;
00048 using typename Base::PolymerModule;
00049
00050 using Base::numEq;
00051
00052
00053
00054
00055
00056 static const bool gasoil = numEq == 2 && (BlackoilIndices::compositionSwitchIdx >= 0);
00057 static const int XvarWell = 0;
00058 static const int WFrac = gasoil? -1000: 1;
00059 static const int GFrac = gasoil? 1: 2;
00060 static const int SFrac = 3;
00061
00062 using typename Base::Scalar;
00063 using typename Base::ConvergenceReport;
00064
00065
00066 using Base::has_solvent;
00067 using Base::has_polymer;
00068 using Base::name;
00069
00070
00071
00072 static const int numWellEq = GET_PROP_VALUE(TypeTag, EnablePolymer)? numEq-1 : numEq;
00073 using typename Base::Mat;
00074 using typename Base::BVector;
00075 using typename Base::Eval;
00076
00077
00078
00079
00080
00081
00082 typedef Dune::FieldVector<Scalar, numWellEq> VectorBlockWellType;
00083 typedef Dune::BlockVector<VectorBlockWellType> BVectorWell;
00084
00085
00086 typedef Dune::FieldMatrix<Scalar, numWellEq, numWellEq > DiagMatrixBlockWellType;
00087 typedef Dune::BCRSMatrix <DiagMatrixBlockWellType> DiagMatWell;
00088
00089
00090 typedef Dune::FieldMatrix<Scalar, numWellEq, numEq> OffDiagMatrixBlockWellType;
00091 typedef Dune::BCRSMatrix<OffDiagMatrixBlockWellType> OffDiagMatWell;
00092
00093 typedef DenseAd::Evaluation<double, numEq + numWellEq> EvalWell;
00094
00095
00096 static const int contiSolventEqIdx = BlackoilIndices::contiSolventEqIdx;
00097 static const int contiPolymerEqIdx = BlackoilIndices::contiPolymerEqIdx;
00098 static const int solventSaturationIdx = BlackoilIndices::solventSaturationIdx;
00099 static const int polymerConcentrationIdx = BlackoilIndices::polymerConcentrationIdx;
00100
00101
00102 StandardWell(const Well* well, const int time_step, const Wells* wells, const ModelParameters& param);
00103
00104 virtual void init(const PhaseUsage* phase_usage_arg,
00105 const std::vector<bool>* active_arg,
00106 const std::vector<double>& depth_arg,
00107 const double gravity_arg,
00108 const int num_cells);
00109
00110
00111 virtual void initPrimaryVariablesEvaluation() const;
00112
00113 virtual void assembleWellEq(Simulator& ebosSimulator,
00114 const double dt,
00115 WellState& well_state,
00116 bool only_wells);
00117
00119
00120 virtual void updateWellStateWithTarget(const int current,
00121 WellState& xw) const;
00122
00124 virtual ConvergenceReport getWellConvergence(const std::vector<double>& B_avg) const;
00125
00127 virtual void apply(const BVector& x, BVector& Ax) const;
00129 virtual void apply(BVector& r) const;
00130
00133 virtual void recoverWellSolutionAndUpdateWellState(const BVector& x,
00134 WellState& well_state) const;
00135
00137 virtual void computeWellPotentials(const Simulator& ebosSimulator,
00138 const WellState& well_state,
00139 std::vector<double>& well_potentials) ;
00140
00141 virtual void updatePrimaryVariables(const WellState& well_state) const;
00142
00143 virtual void solveEqAndUpdateWellState(WellState& well_state);
00144
00145 virtual void calculateExplicitQuantities(const Simulator& ebosSimulator,
00146 const WellState& well_state);
00147 protected:
00148
00149
00150 using Base::getAllowCrossFlow;
00151 using Base::phaseUsage;
00152 using Base::active;
00153 using Base::flowPhaseToEbosPhaseIdx;
00154 using Base::flowPhaseToEbosCompIdx;
00155 using Base::numComponents;
00156 using Base::wsolvent;
00157 using Base::wpolymer;
00158 using Base::wellHasTHPConstraints;
00159 using Base::mostStrictBhpFromBhpLimits;
00160
00161
00162 using Base::vfp_properties_;
00163 using Base::gravity_;
00164 using Base::param_;
00165 using Base::well_efficiency_factor_;
00166 using Base::first_perf_;
00167 using Base::ref_depth_;
00168 using Base::perf_depth_;
00169 using Base::well_cells_;
00170 using Base::number_of_perforations_;
00171 using Base::number_of_phases_;
00172 using Base::saturation_table_number_;
00173 using Base::comp_frac_;
00174 using Base::well_index_;
00175 using Base::index_of_well_;
00176 using Base::well_controls_;
00177 using Base::well_type_;
00178
00179 using Base::perf_rep_radius_;
00180 using Base::perf_length_;
00181 using Base::bore_diameters_;
00182
00183
00184 std::vector<double> perf_densities_;
00185
00186 std::vector<double> perf_pressure_diffs_;
00187
00188
00189 BVectorWell resWell_;
00190
00191
00192 OffDiagMatWell duneB_;
00193 OffDiagMatWell duneC_;
00194
00195 DiagMatWell invDuneD_;
00196
00197
00198 mutable BVectorWell Bx_;
00199 mutable BVectorWell invDrw_;
00200
00201
00202
00203 mutable std::vector<double> primary_variables_;
00204
00205
00206 mutable std::vector<EvalWell> primary_variables_evaluation_;
00207
00208
00209 std::vector<double> F0_;
00210
00211
00212
00213
00214 EvalWell getBhp() const;
00215
00216
00217 EvalWell getQs(const int comp_idx) const;
00218
00219 EvalWell wellVolumeFractionScaled(const int phase) const;
00220
00221 EvalWell wellVolumeFraction(const int phase) const;
00222
00223 EvalWell wellSurfaceVolumeFraction(const int phase) const;
00224
00225 EvalWell extendEval(const Eval& in) const;
00226
00227 bool crossFlowAllowed(const Simulator& ebosSimulator) const;
00228
00229
00230 void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
00231
00232
00233 void updateWellState(const BVectorWell& dwells,
00234 WellState& well_state) const;
00235
00236
00237
00238 void computePropertiesForWellConnectionPressures(const Simulator& ebosSimulator,
00239 const WellState& xw,
00240 std::vector<double>& b_perf,
00241 std::vector<double>& rsmax_perf,
00242 std::vector<double>& rvmax_perf,
00243 std::vector<double>& surf_dens_perf) const;
00244
00245
00246
00247 void computeConnectionDensities(const std::vector<double>& perfComponentRates,
00248 const std::vector<double>& b_perf,
00249 const std::vector<double>& rsmax_perf,
00250 const std::vector<double>& rvmax_perf,
00251 const std::vector<double>& surf_dens_perf);
00252
00253 void computeConnectionPressureDelta();
00254
00255 void computeWellConnectionDensitesPressures(const WellState& xw,
00256 const std::vector<double>& b_perf,
00257 const std::vector<double>& rsmax_perf,
00258 const std::vector<double>& rvmax_perf,
00259 const std::vector<double>& surf_dens_perf);
00260
00261
00262 void computeAccumWell();
00263
00264 void computeWellConnectionPressures(const Simulator& ebosSimulator,
00265 const WellState& xw);
00266
00267
00268 void computePerfRate(const IntensiveQuantities& intQuants,
00269 const std::vector<EvalWell>& mob_perfcells_dense,
00270 const double Tw, const EvalWell& bhp, const double& cdp,
00271 const bool& allow_cf, std::vector<EvalWell>& cq_s) const;
00272
00273
00274
00275 void computeWellRatesWithBhp(const Simulator& ebosSimulator,
00276 const EvalWell& bhp,
00277 std::vector<double>& well_flux) const;
00278
00279 std::vector<double> computeWellPotentialWithTHP(const Simulator& ebosSimulator,
00280 const double initial_bhp,
00281 const std::vector<double>& initial_potential) const;
00282
00283 template <class ValueType>
00284 ValueType calculateBhpFromThp(const std::vector<ValueType>& rates, const int control_index) const;
00285
00286 double calculateThpFromBhp(const std::vector<double>& rates, const int control_index, const double bhp) const;
00287
00288
00289 void getMobility(const Simulator& ebosSimulator,
00290 const int perf,
00291 std::vector<EvalWell>& mob) const;
00292
00293 double scalingFactor(const int comp_idx) const;
00294 };
00295
00296 }
00297
00298 #include "StandardWell_impl.hpp"
00299
00300 #endif // OPM_STANDARDWELL_HEADER_INCLUDED