00001
00009 #ifndef BS_MAIN_LOOP_CALC_COMPUTE_ACC_RATES_H_
00010 #define BS_MAIN_LOOP_CALC_COMPUTE_ACC_RATES_H_
00011
00012 #include "apply_wefac.h"
00013
00014 namespace blue_sky
00015 {
00016
00021 template <typename strategy_t, bool is_w, bool is_g, bool is_o>
00022 inline void
00023 main_loop_calc <strategy_t, is_w, is_g, is_o>::compute_acc_rates ()
00024 {
00025 typedef typename calc_model_t::strategy_type strategy_type;
00026 typedef typename calc_model_t::well_t well_t;
00027 typedef typename calc_model_t::reservoir_t::facility_manager_t::well_const_iterator_t well_iterator_t;
00028
00029 typedef typename calc_model_t::sp_well_t sp_well_t;
00030
00031 well_iterator_t wb = reservoir_->get_facility_list ()->wells_begin ();
00032 well_iterator_t we = reservoir_->get_facility_list ()->wells_end ();
00033
00034 typename reservoir_t::rate_data_t &rs_rate = reservoir_->rate_;
00035 typename reservoir_t::rate_data_t &rs_rate_rc = reservoir_->rate_rc_;
00036 typename reservoir_t::rate_data_t &rs_rate_wefac = reservoir_->rate_wefac_;
00037 typename reservoir_t::rate_data_t &rs_rate_rc_wefac = reservoir_->rate_rc_wefac_;
00038 typename reservoir_t::rate_data_t &rs_rate_initial = reservoir_->rate_initial_;
00039 typename reservoir_t::rate_data_t &rs_rate_total = reservoir_->rate_total_;
00040
00041 rs_rate = 0;
00042 rs_rate_rc = 0;
00043 rs_rate_wefac = 0;
00044 rs_rate_rc_wefac = 0;
00045 rs_rate_initial = 0;
00046 rs_rate_total = 0;
00047
00048 for (; wb != we; ++wb)
00049 {
00050 sp_well_t well (wb->second, bs_dynamic_cast ());
00051
00052 bool is_prod = well->get_well_controller ()->is_production ();
00053 item_t wefac = apply_wefac (1.0, well->exploitation_factor_);
00054 item_t wefac_dt = apply_wefac (dt_, wefac);
00055
00056
00057
00058
00059
00060 if (is_prod)
00061 {
00062 well->rate_total_.prod += well->rate ().prod * wefac_dt;
00063 }
00064 else
00065 {
00066 well->rate_total_.inj += well->rate ().inj * wefac_dt;
00067 }
00068
00069 rs_rate += well->rate ();
00070 rs_rate_rc += well->rate_rc_;
00071 rs_rate_wefac += well->rate () * wefac;
00072 rs_rate_rc_wefac += well->rate_rc_ * wefac;
00073 rs_rate_initial += well->rate () * wefac;
00074 rs_rate_total += well->rate_total_;
00075 }
00076 }
00077
00078
00079 }
00080
00081
00082
00083 #endif // #ifndef BS_MAIN_LOOP_CALC_COMPUTE_ACC_RATES_H_