00001
00009 #ifndef __BS_WELL_RESULTS_STORAGE_H
00010 #define __BS_WELL_RESULTS_STORAGE_H
00011
00012 #include "well_rate_control.h"
00013 #include "apply_wefac.h"
00014 #include "rate_control_type.h"
00015 #include "fi_params.h"
00016
00017
00018 namespace blue_sky
00019 {
00020
00025 enum well_d_params
00026 {
00027 WELL_D_PARAM_COR = 0,
00028 WELL_D_PARAM_CWR,
00029 WELL_D_PARAM_CGR,
00030 WELL_D_PARAM_CLR,
00031 WELL_D_PARAM_COI,
00032 WELL_D_PARAM_CWI,
00033 WELL_D_PARAM_CGI,
00034
00035 WELL_D_PARAM_HCOR,
00036 WELL_D_PARAM_HCWR,
00037 WELL_D_PARAM_HCGR,
00038 WELL_D_PARAM_HCLR,
00039 WELL_D_PARAM_HCOI,
00040 WELL_D_PARAM_HCWI,
00041 WELL_D_PARAM_HCGI,
00042
00043 WELL_D_PARAM_CBHP,
00044 WELL_D_PARAM_HBHP,
00045
00046 WELL_D_PARAM_TOR,
00047 WELL_D_PARAM_TWR,
00048 WELL_D_PARAM_TGR,
00049 WELL_D_PARAM_TLR,
00050 WELL_D_PARAM_TOI,
00051 WELL_D_PARAM_TWI,
00052 WELL_D_PARAM_TGI,
00053
00054 WELL_D_PARAM_HTOR,
00055 WELL_D_PARAM_HTWR,
00056 WELL_D_PARAM_HTGR,
00057 WELL_D_PARAM_HTLR,
00058 WELL_D_PARAM_HTOI,
00059 WELL_D_PARAM_HTWI,
00060 WELL_D_PARAM_HTGI,
00061 WELL_D_PARAM_WEFAC,
00062 WELL_D_PARAM_WBP1,
00063 WELL_D_PARAM_WBP4,
00064 WELL_D_PARAM_WBP5,
00065 WELL_D_PARAM_WBP9,
00066
00067
00068 WELL_D_PARAM_COUNT
00069 };
00070
00075 enum conn_d_params
00076 {
00077 CONN_D_PARAM_COR = 0,
00078 CONN_D_PARAM_CWR,
00079 CONN_D_PARAM_CGR,
00080 CONN_D_PARAM_CLR,
00081 CONN_D_PARAM_COI,
00082 CONN_D_PARAM_CWI,
00083 CONN_D_PARAM_CGI,
00084 CONN_D_PARAM_BHP,
00085 CONN_D_PARAM_BULKP,
00086 CONN_D_PARAM_TOR,
00087 CONN_D_PARAM_TWR,
00088 CONN_D_PARAM_TGR,
00089 CONN_D_PARAM_TLR,
00090 CONN_D_PARAM_TOI,
00091 CONN_D_PARAM_TWI,
00092 CONN_D_PARAM_TGI,
00093 CONN_D_PARAM_FACTOR,
00094 CONN_D_PARAM_DEPTH,
00095
00096
00097 CONN_D_PARAM_COUNT
00098 };
00099
00104 enum conn_i_params
00105 {
00106 CONN_I_PARAM_STATUS = 0,
00107 CONN_I_PARAM_GRP_STATUS,
00108 CONN_I_PARAM_I,
00109 CONN_I_PARAM_J,
00110 CONN_I_PARAM_K1,
00111 CONN_I_PARAM_K2,
00112 CONN_I_PARAM_NBLOCK,
00113
00114
00115 CONN_I_PARAM_COUNT
00116 };
00117
00123 enum well_i_params
00124 {
00125 WELL_I_PARAM_HSTATUS = 0,
00126 WELL_I_PARAM_STATUS,
00127
00128
00129 WELL_I_PARAM_COUNT
00130 };
00131
00136 class BS_API_PLUGIN connection_results
00137 {
00138
00139 public:
00140 connection_results ();
00141 ~connection_results ();
00142
00143 void
00144 clear ();
00145
00146
00147 public:
00148 typedef std::vector<double> dates_type;
00149 typedef std::vector<float> d_params_internal_type;
00150 typedef std::vector<d_params_internal_type> d_params_type;
00151 typedef std::vector<int> i_params_internal_type;
00152 typedef std::vector<i_params_internal_type> i_params_type;
00153
00154 dates_type dates;
00155 d_params_type d_params;
00156 i_params_type i_params;
00157 };
00158
00163 class BS_API_PLUGIN well_results
00164 {
00165
00166 public:
00167 well_results ();
00168 ~well_results ();
00169
00170 void
00171 clear ();
00172
00173
00174 public:
00175 typedef std::vector<double> dates_type;
00176 typedef std::vector<float> d_params_internal_type;
00177 typedef std::vector<d_params_internal_type> d_params_type;
00178 typedef std::vector<int> i_params_internal_type;
00179 typedef std::vector<i_params_internal_type> i_params_type;
00180 typedef std::map<int, connection_results> conn_type;
00181 typedef std::pair<int, connection_results> conn_pair_type;
00182
00183 conn_type connections;
00184 dates_type dates;
00185 d_params_type d_params;
00186 i_params_type i_params;
00187 std::string group;
00188 };
00189
00194 class BS_API_PLUGIN well_results_storage : public objbase
00195 {
00196 BLUE_SKY_TYPE_DECL (well_results_storage);
00197
00198 public:
00199 ~well_results_storage ();
00200
00201
00202 public:
00203 typedef std::map<std::string, well_results> wells_type;
00204 typedef std::pair<std::string, well_results> wells_pair_type;
00205
00206 wells_type wells;
00207 };
00208
00209
00214 template <typename strategy_t>
00215 struct save_well_data
00216 {
00217 typedef calc_model <strategy_t> calc_model_t;
00218 typedef typename strategy_t::index_t index_t;
00219
00220 typedef typename calc_model_t::data_array_t data_array_t;
00221 typedef typename calc_model_t::item_t item_t;
00222 typedef typename calc_model_t::connection_t connection_t;
00223 typedef typename calc_model_t::well_t well_t;
00224 typedef typename calc_model_t::strategy_type strategy_type;
00225
00226 typedef smart_ptr <calc_model_t, true> sp_calc_model_t;
00227 typedef typename calc_model_t::sp_well_t sp_well_t;
00228 typedef typename calc_model_t::sp_connection_t sp_connection_t;
00229 typedef smart_ptr<well_results_storage, true> sp_well_results_storage;
00230
00231 typedef typename calc_model_t::reservoir_t::facility_manager_t facility_manager_t;
00232 typedef typename facility_manager_t::well_const_iterator_t well_iterator_t;
00233
00243 void
00244 copy_well_data_to_storage (sp_calc_model_t &calc_model, item_t , well_iterator_t wb, const well_iterator_t &we, size_t , item_t time)
00245 {
00246 const sp_well_results_storage &w_res (calc_model->well_res);
00247
00248
00249 for (well_iterator_t well = wb; well != we; ++well)
00250 {
00251 sp_well_t ws (well->second, bs_dynamic_cast ());
00252 well_results &wr = w_res->wells[ws->get_name ()];
00253
00254 wr.group = std::string ("FIELD");
00255
00256 wr.dates.push_back (time);
00257
00258
00259 wr.d_params[WELL_D_PARAM_COR].push_back (-(float)ws->rate ().prod.oil);
00260 wr.d_params[WELL_D_PARAM_CWR].push_back (-(float)ws->rate ().prod.water);
00261 wr.d_params[WELL_D_PARAM_CGR].push_back (-(float)ws->rate ().prod.gas);
00262 wr.d_params[WELL_D_PARAM_CLR].push_back (-(float)ws->rate ().prod.liquid);
00263 wr.d_params[WELL_D_PARAM_COI].push_back ((float)ws->rate ().inj.oil);
00264 wr.d_params[WELL_D_PARAM_CWI].push_back ((float)ws->rate ().inj.water);
00265 wr.d_params[WELL_D_PARAM_CGI].push_back ((float)ws->rate ().inj.gas);
00266
00267
00268
00269 wr.d_params[WELL_D_PARAM_HCOR].push_back (0);
00270 wr.d_params[WELL_D_PARAM_HCWR].push_back (0);
00271 wr.d_params[WELL_D_PARAM_HCGR].push_back (0);
00272 wr.d_params[WELL_D_PARAM_HCLR].push_back (0);
00273 wr.d_params[WELL_D_PARAM_HCOI].push_back (0);
00274 wr.d_params[WELL_D_PARAM_HCWI].push_back (0);
00275 wr.d_params[WELL_D_PARAM_HCGI].push_back (0);
00276
00277 wr.d_params[WELL_D_PARAM_TOR].push_back (-(float)ws->rate_total ().prod.oil);
00278 wr.d_params[WELL_D_PARAM_TWR].push_back (-(float)ws->rate_total ().prod.water);
00279 wr.d_params[WELL_D_PARAM_TGR].push_back (-(float)ws->rate_total ().prod.gas);
00280 wr.d_params[WELL_D_PARAM_TLR].push_back (-(float)ws->rate_total ().prod.liquid);
00281 wr.d_params[WELL_D_PARAM_TOI].push_back ((float)ws->rate_total ().inj.oil);
00282 wr.d_params[WELL_D_PARAM_TWI].push_back ((float)ws->rate_total ().inj.water);
00283 wr.d_params[WELL_D_PARAM_TGI].push_back ((float)ws->rate_total ().inj.gas);
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 wr.d_params[WELL_D_PARAM_CBHP].push_back ((float)ws->get_well_controller ()->bhp ());
00297 wr.d_params[WELL_D_PARAM_HBHP].push_back ((float)ws->get_well_controller ()->bhp_history ());
00298
00299
00300 using namespace wells;
00301 int status = -999, producer = 0;
00302 if (ws->get_well_controller ()->is_production ())
00303 producer = 1;
00304 rate_control_type control_type = ws->get_well_controller ()->get_control_type ();
00305 if (!ws->is_open ())
00306 {
00307 status = 0;
00308 }
00309 else if (control_type == bhp_control)
00310 {
00311 if (producer)
00312 status = -2;
00313 else
00314 status = 2;
00315 }
00316 else if (control_type == oil_rate_control)
00317 {
00318 status = -4;
00319 }
00320 else if (control_type == water_rate_control)
00321 {
00322 if (producer)
00323 status = -3;
00324 else
00325 status = 1;
00326 }
00327 else if (control_type == gas_rate_control)
00328 {
00329 status = -5;
00330 }
00331 else if (control_type == rate_control)
00332 {
00333 status = 3;
00334 }
00335 else if (control_type == liquid_rate_control)
00336 {
00337 status = -1;
00338 }
00339
00340 wr.i_params[WELL_I_PARAM_HSTATUS].push_back (0);
00341 wr.i_params[WELL_I_PARAM_STATUS].push_back (status);
00342
00343 if (calc_model->ts_params->get_bool (fi_params::WRITE_CONN_RESULTS_TO_HDF5))
00344 {
00345 for (size_t i = 0, cnt = ws->get_connections_count (); i < cnt; ++i)
00346 {
00347 const sp_connection_t &ci = ws->get_connection (i);
00348 int cell = ci->n_block ();
00349 connection_results &cr = wr.connections[cell];
00350 cr.dates.push_back (time);
00351
00352 if (!ci->is_shut ())
00353 {
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 }
00364 else
00365 {
00366 cr.d_params[CONN_D_PARAM_COR].push_back (0);
00367 cr.d_params[CONN_D_PARAM_CWR].push_back (0);
00368 cr.d_params[CONN_D_PARAM_CGR].push_back (0);
00369 cr.d_params[CONN_D_PARAM_CLR].push_back (0);
00370 cr.d_params[CONN_D_PARAM_COI].push_back (0);
00371 cr.d_params[CONN_D_PARAM_CWI].push_back (0);
00372 cr.d_params[CONN_D_PARAM_CGI].push_back (0);
00373 }
00374
00375 cr.d_params[CONN_D_PARAM_FACTOR].push_back ((float)ci->get_fact ());
00376 cr.d_params[CONN_D_PARAM_BHP].push_back ((float)ci->get_cur_bhp ());
00377 cr.d_params[CONN_D_PARAM_BULKP].push_back ((float)ci->get_bulkp ());
00378 cr.d_params[CONN_D_PARAM_DEPTH].push_back ((float)ci->connection_depth);
00379
00380 cr.i_params[CONN_I_PARAM_STATUS].push_back (ci->get_status ());
00381 cr.i_params[CONN_I_PARAM_GRP_STATUS].push_back (0);
00382 cr.i_params[CONN_I_PARAM_I].push_back (ci->i_coord ());
00383 cr.i_params[CONN_I_PARAM_J].push_back (ci->j_coord ());
00384 cr.i_params[CONN_I_PARAM_K1].push_back (ci->k_coord ());
00385 cr.i_params[CONN_I_PARAM_K2].push_back (ci->k_coord ());
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396 }
00397
00398 }
00399 }
00400 }
00401 };
00402
00403 }
00404 #endif //__BS_WELL_RESULTS_STORAGE_H