void check_controls_epoch0( struct WellControls ** ctrls) { // The injector { const struct WellControls * ctrls0 = ctrls[0]; BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0) ); BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1) ); BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2) ); // The different targets BOOST_CHECK_EQUAL( 100.0 / 86400 , well_controls_iget_target(ctrls0,0)); BOOST_CHECK_EQUAL( 200.0 / 86400 , well_controls_iget_target(ctrls0,1)); BOOST_CHECK_EQUAL( 400 * 100000 , well_controls_iget_target(ctrls0,2)); // Which control is active BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls0) ); // The phase distribution in the active target { const double * distr = well_controls_iget_distr( ctrls0 , 0 ); BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas } } // The producer { const struct WellControls * ctrls1 = ctrls[1]; BOOST_CHECK_EQUAL( 2 , well_controls_get_num( ctrls1 )); // The number of controls for the producer == 2?? BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) ); BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 1) ); // The different targets BOOST_CHECK_EQUAL( -20000.0 / 86400 , well_controls_iget_target(ctrls1,0)); BOOST_CHECK_EQUAL( 1000 * 100000 , well_controls_iget_target(ctrls1,1)); // Which control is active BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls1)); // The phase distribution in the active target { const double * distr = well_controls_iget_distr( ctrls1 , 0 ); BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas } } }
void check_controls_epoch1( struct WellControls ** ctrls) { // The injector { const struct WellControls * ctrls0 = ctrls[0]; BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0 )); BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1 )); BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2 )); // The different targets BOOST_CHECK_CLOSE( 10.0 / 86400 , well_controls_iget_target(ctrls0 , 0) , 0.001); BOOST_CHECK_CLOSE( 20.0 / 86400 , well_controls_iget_target(ctrls0 , 1) , 0.001); BOOST_CHECK_CLOSE( 40 * 100000 , well_controls_iget_target(ctrls0 , 2) , 0.001); // Which control is active BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls0)); { const double * distr = well_controls_iget_distr( ctrls0 , 1 ); BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas } } // The producer { const struct WellControls * ctrls1 = ctrls[1]; BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls1)); // The number of controls for the producer - now 3. BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) ); BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls1 , 1) ); BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 2) ); // The different targets BOOST_CHECK_CLOSE( -999.0 / 86400 , well_controls_iget_target(ctrls1 , 0), 0.001); BOOST_CHECK_CLOSE( -123.0 / 86400 , well_controls_iget_target(ctrls1 , 1), 0.001); BOOST_CHECK_CLOSE( 100 * 100000 , well_controls_iget_target(ctrls1 , 2), 0.001); // Which control is active BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls1) ); { const double * distr = well_controls_iget_distr( ctrls1 , 1 ); BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas } } }
/// Create a src vector equivalent to a wells structure. /// For this to be valid, the wells must be all rate-controlled and /// single-perforation. void wellsToSrc(const Wells& wells, const int num_cells, std::vector<double>& src) { const int np = wells.number_of_phases; if (np != 2) { OPM_THROW(std::runtime_error, "wellsToSrc() requires a 2 phase case."); } src.resize(num_cells); for (int w = 0; w < wells.number_of_wells; ++w) { const int cur = well_controls_get_current(wells.ctrls[w]); if (well_controls_get_num(wells.ctrls[w]) != 1) { OPM_MESSAGE("In wellsToSrc(): well has more than one control, all but current control will be ignored."); } if (well_controls_iget_type(wells.ctrls[w] , cur) != RESERVOIR_RATE) { OPM_THROW(std::runtime_error, "In wellsToSrc(): well is something other than RESERVOIR_RATE."); } if (wells.well_connpos[w+1] - wells.well_connpos[w] != 1) { OPM_THROW(std::runtime_error, "In wellsToSrc(): well has multiple perforations."); } { const double * distr = well_controls_iget_distr( wells.ctrls[w] , cur); for (int p = 0; p < np; ++p) { if (distr[p] != 1.0) { OPM_THROW(std::runtime_error, "In wellsToSrc(): well not controlled on total rate."); } } } double flow = well_controls_iget_target(wells.ctrls[w] , cur); if (wells.type[w] == INJECTOR) { flow *= wells.comp_frac[np*w + 0]; // Obtaining water rate for inflow source. } const int cell = wells.well_cells[wells.well_connpos[w]]; src[cell] = flow; } }