2012-03-29 11:34:51 -05:00
|
|
|
/*
|
2013-01-29 06:42:24 -06:00
|
|
|
Copyright 2011 SINTEF ICT, Applied Mathematics.
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-01-29 06:42:24 -06:00
|
|
|
This file is part of the Open Porous Media project (OPM).
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-01-29 06:42:24 -06:00
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-01-29 06:42:24 -06:00
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2013-01-29 06:42:24 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2012-03-29 11:34:51 -05:00
|
|
|
#ifndef OPM_WELLCOLLECTION_HPP
|
|
|
|
#define OPM_WELLCOLLECTION_HPP
|
|
|
|
|
|
|
|
#include <vector>
|
2014-02-12 08:39:57 -06:00
|
|
|
#include <memory>
|
|
|
|
|
2012-06-05 08:42:49 -05:00
|
|
|
#include <opm/core/wells/WellsGroup.hpp>
|
2012-04-12 07:25:39 -05:00
|
|
|
#include <opm/core/grid.h>
|
2014-02-12 08:39:57 -06:00
|
|
|
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
|
2012-03-29 11:34:51 -05:00
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
class WellCollection
|
|
|
|
{
|
|
|
|
public:
|
2014-02-12 08:39:57 -06:00
|
|
|
|
2016-10-05 08:24:14 -05:00
|
|
|
void addField(const Group& fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage);
|
2014-02-12 08:39:57 -06:00
|
|
|
|
2016-06-16 02:33:43 -05:00
|
|
|
void addWell(const Well* wellChild, size_t timeStep, const PhaseUsage& phaseUsage);
|
2014-02-12 08:39:57 -06:00
|
|
|
|
2016-10-05 08:24:14 -05:00
|
|
|
void addGroup(const Group& groupChild, std::string parent_name,
|
2014-02-12 08:39:57 -06:00
|
|
|
size_t timeStep, const PhaseUsage& phaseUsage);
|
|
|
|
|
2012-05-14 09:10:37 -05:00
|
|
|
/// Adds the child to the collection
|
|
|
|
/// and appends it to parent's children.
|
|
|
|
/// \param[in] child the child node
|
|
|
|
/// \param[in] parent name of parent node
|
2013-08-08 05:32:01 -05:00
|
|
|
void addChild(std::shared_ptr<WellsGroupInterface>& child_node,
|
2012-05-14 09:10:37 -05:00
|
|
|
const std::string& parent);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-14 09:10:37 -05:00
|
|
|
/// Adds the node to the collection (as a root node)
|
2013-08-08 05:32:01 -05:00
|
|
|
void addChild(std::shared_ptr<WellsGroupInterface>& child_node);
|
2012-03-29 11:34:51 -05:00
|
|
|
|
2012-04-25 09:40:31 -05:00
|
|
|
/// Checks if each condition is met, applies well controls where needed
|
|
|
|
/// (that is, it either changes the active control of violating wells, or shuts
|
|
|
|
/// down wells). Only one change is applied per invocation. Typical use will be
|
|
|
|
/// \code
|
|
|
|
/// solve_pressure();
|
|
|
|
/// while(!collection.conditionsMet(well_bhp, well_rate, summed_phases)) {
|
|
|
|
/// solve_pressure();
|
|
|
|
/// }
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \note It's highly recommended to use the conditionsMet found in WellsManager.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
2012-04-25 09:40:31 -05:00
|
|
|
/// to be ordered the same way as the related Wells-struct.
|
2012-05-02 06:02:59 -05:00
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
2012-04-25 09:40:31 -05:00
|
|
|
/// \return true if no violations were found, false otherwise (false also implies a change).
|
2012-04-25 09:14:40 -05:00
|
|
|
bool conditionsMet(const std::vector<double>& well_bhp,
|
2012-05-02 06:02:59 -05:00
|
|
|
const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 07:19:47 -05:00
|
|
|
/// Adds the well pointer to each leaf node (does not take ownership).
|
2012-04-25 09:14:40 -05:00
|
|
|
void setWellsPointer(Wells* wells);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 09:40:31 -05:00
|
|
|
/// \return A set of pointers to every well in the collection
|
2012-04-25 07:19:47 -05:00
|
|
|
const std::vector<WellNode*>& getLeafNodes() const;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 09:40:31 -05:00
|
|
|
/// Finds the group with the given name.
|
|
|
|
/// \param[in] the name of the group
|
|
|
|
/// \return the pointer to the group if found, NULL otherwise
|
2012-04-25 09:42:55 -05:00
|
|
|
WellsGroupInterface* findNode(const std::string& name);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 09:40:31 -05:00
|
|
|
/// Finds the group with the given name.
|
|
|
|
/// \param[in] the name of the group
|
|
|
|
/// \return the pointer to the group if found, NULL otherwise
|
2012-04-25 09:42:55 -05:00
|
|
|
const WellsGroupInterface* findNode(const std::string& name) const;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-02 06:02:59 -05:00
|
|
|
/// Applies all group controls (injection and production)
|
|
|
|
void applyGroupControls();
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-09 06:03:37 -05:00
|
|
|
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2016-09-30 10:54:49 -05:00
|
|
|
/// Checking whehter need to update the targets of the wells / or the groups later
|
|
|
|
/// True need to update well targets within this iteration, no switching control within this iteration.
|
|
|
|
/// False no need to update well targets within this iteration, continuing as usual.
|
|
|
|
/// TODO: currently return true whenever a wellNode needs to be updated. Later some more sophiscated
|
|
|
|
/// strategy might be required.
|
|
|
|
bool needUpdateWellTargets() const;
|
|
|
|
|
2016-10-07 07:54:53 -05:00
|
|
|
bool needUpdateInjectionTargets() const;
|
|
|
|
bool needUpdateProductionTargets() const;
|
|
|
|
|
2016-10-10 04:37:22 -05:00
|
|
|
size_t numNode() const;
|
2016-09-30 10:54:49 -05:00
|
|
|
|
|
|
|
WellNode* getNode(size_t i) const;
|
|
|
|
|
2016-10-10 07:47:19 -05:00
|
|
|
void updateWellTargets(const std::vector<double> well_rates);
|
2016-09-30 10:54:49 -05:00
|
|
|
|
2016-10-06 11:00:08 -05:00
|
|
|
bool justUpdateWellTargets() const;
|
|
|
|
|
|
|
|
void setJustUpdateWellTargets(const bool flag);
|
|
|
|
|
2012-03-29 11:34:51 -05:00
|
|
|
private:
|
|
|
|
// To account for the possibility of a forest
|
2013-08-08 05:32:01 -05:00
|
|
|
std::vector<std::shared_ptr<WellsGroupInterface> > roots_;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-03-30 03:51:31 -05:00
|
|
|
// This will be used to traverse the bottom nodes.
|
2012-04-25 07:19:47 -05:00
|
|
|
std::vector<WellNode*> leaf_nodes_;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2016-10-06 11:00:08 -05:00
|
|
|
bool just_update_well_targets_;
|
|
|
|
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-03-29 11:34:51 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
2016-09-30 10:54:49 -05:00
|
|
|
|
2012-03-29 11:34:51 -05:00
|
|
|
#endif /* OPM_WELLCOLLECTION_HPP */
|
|
|
|
|