00001
00011 #ifndef BS_WELLS_WELL_RATE_CONTROL_COMPUTE_POTENTIALS_H_
00012 #define BS_WELLS_WELL_RATE_CONTROL_COMPUTE_POTENTIALS_H_
00013
00014 namespace blue_sky
00015 {
00016
00017 template <typename data_t, typename params_t>
00018 inline void
00019 compute_potentials (const data_t &data, params_t ¶ms)
00020 {
00021 typedef typename params_t::item_t item_t;
00022
00023 const item_t &bhp = params.perf_bhp;
00024 const item_t &po = params.pressure[params.n_block];
00025
00026
00027
00028
00029
00030 params.Po = bhp - po;
00031 params.Pw = params.Po;
00032 params.Pg = params.Po;
00033
00034 if (params.is_w)
00035 params.Pw -= CAP_PRESSURE (data, params.phase_d, FI_PHASE_WATER);
00036
00037 if (params.is_g)
00038 params.Pg -= CAP_PRESSURE (data, params.phase_d, FI_PHASE_GAS);
00039
00040 #ifdef _DEBUG
00041
00042 BOSOUT (section::wells, level::debug) << boost::format ("[%d]: bhp: %.10e, pref: %.10e") % params.n_block % bhp % po << bs_end;
00043 BOSOUT (section::wells, level::debug) << boost::format ("[%d]: pw: %.10e pg: %.10e po: %.10e") % params.n_block % params.Pw % params.Pg % params.Po << bs_end;
00044 #endif
00045 }
00046
00047 template <typename params_t>
00048 inline bool
00049 is_prod_potential (const params_t ¶ms)
00050 {
00051 return params.Po < typename params_t::item_t (0.0);
00052 }
00053
00054 }
00055
00056
00057
00058 #endif // #ifndef BS_WELLS_WELL_RATE_CONTROL_COMPUTE_POTENTIALS_H_
00059