{"action":"opened","issue":{"url":"https://api.github.com/repos/OPM/opm-parser/issues/829","repository_url":"https://api.github.com/repos/OPM/opm-parser","labels_url":"https://api.github.com/repos/OPM/opm-parser/issues/829/labels{/name}","comments_url":"https://api.github.com/repos/OPM/opm-parser/issues/829/comments","events_url":"https://api.github.com/repos/OPM/opm-parser/issues/829/events","html_url":"https://github.com/OPM/opm-parser/issues/829","id":158905403,"number":829,"title":"Production controls added for phases that don't exist","user":{"login":"ANerd","id":1568592,"avatar_url":"https://avatars.githubusercontent.com/u/1568592?v=3","gravatar_id":"","url":"https://api.github.com/users/ANerd","html_url":"https://github.com/ANerd","followers_url":"https://api.github.com/users/ANerd/followers","following_url":"https://api.github.com/users/ANerd/following{/other_user}","gists_url":"https://api.github.com/users/ANerd/gists{/gist_id}","starred_url":"https://api.github.com/users/ANerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ANerd/subscriptions","organizations_url":"https://api.github.com/users/ANerd/orgs","repos_url":"https://api.github.com/users/ANerd/repos","events_url":"https://api.github.com/users/ANerd/events{/privacy}","received_events_url":"https://api.github.com/users/ANerd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-07T12:00:23Z","updated_at":"2016-06-07T12:00:23Z","closed_at":null,"body":"I am trying to run a two-phase problem (oil-water) in flow (master branch), but I get the following exception:\r\n\r\n> [<...>/opm-core/opm/core/wells/WellsManager.cpp:599] Gas phase not active and GRAT control specified.\r\n\r\nAfter some investigation I found the code where the GRAT-control is added, which is [here](https://github.com/OPM/opm-parser/blob/c46b1cb9369d328056bd6a9e45513cbca5420650/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp#L52) (the case uses WCONHIST):\r\n```cpp\r\nfor (auto const& modeKey : {\"ORAT\", \"WRAT\", \"GRAT\", \"LRAT\", \"RESV\", \"GRUP\"}) {\r\n    auto cmode = WellProducer::ControlModeFromString( modeKey );\r\n    p.addProductionControl( cmode );\r\n}\r\n````\r\nThis code seems to add all production controls without checking what phases are active. Just removing \"GRAT\" from this list fixes the problem (but that will obviously break something for three-phase runs).\r\n\r\nThe code for prediction mode ([here](https://github.com/OPM/opm-parser/blob/c46b1cb9369d328056bd6a9e45513cbca5420650/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp#L95)) seems to be doing something smarter\r\n```cpp\r\nfor (auto const& modeKey : {\"ORAT\", \"WRAT\", \"GRAT\", \"LRAT\",\"RESV\", \"BHP\" , \"THP\"}) {\r\n    if (!record.getItem(modeKey).defaultApplied(0)) {\r\n        auto cmode = WellProducer::ControlModeFromString( modeKey );\r\n        p.addProductionControl( cmode );\r\n    }\r\n}\r\n```\r\n\r\nI imagine the issue can be fixed by something like [this](https://gist.github.com/ANerd/adc224e99890ebff75cbed4959139d82), but I don't know enough about the code to know if this breaks something else."}}
{"actor":{"display_login":"ANerd"}}