{"action":"opened","issue":{"url":"https://api.github.com/repos/quintel/etengine/issues/813","labels_url":"https://api.github.com/repos/quintel/etengine/issues/813/labels{/name}","comments_url":"https://api.github.com/repos/quintel/etengine/issues/813/comments","events_url":"https://api.github.com/repos/quintel/etengine/issues/813/events","html_url":"https://github.com/quintel/etengine/issues/813","id":127657095,"number":813,"title":"Adding a number_of_units attribute for converters","user":{"login":"RobTerwel","id":14106387,"avatar_url":"https://avatars.githubusercontent.com/u/14106387?v=3","gravatar_id":"","url":"https://api.github.com/users/RobTerwel","html_url":"https://github.com/RobTerwel","followers_url":"https://api.github.com/users/RobTerwel/followers","following_url":"https://api.github.com/users/RobTerwel/following{/other_user}","gists_url":"https://api.github.com/users/RobTerwel/gists{/gist_id}","starred_url":"https://api.github.com/users/RobTerwel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobTerwel/subscriptions","organizations_url":"https://api.github.com/users/RobTerwel/orgs","repos_url":"https://api.github.com/users/RobTerwel/repos","events_url":"https://api.github.com/users/RobTerwel/events{/privacy}","received_events_url":"https://api.github.com/users/RobTerwel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"antw","id":4383,"avatar_url":"https://avatars.githubusercontent.com/u/4383?v=3","gravatar_id":"","url":"https://api.github.com/users/antw","html_url":"https://github.com/antw","followers_url":"https://api.github.com/users/antw/followers","following_url":"https://api.github.com/users/antw/following{/other_user}","gists_url":"https://api.github.com/users/antw/gists{/gist_id}","starred_url":"https://api.github.com/users/antw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antw/subscriptions","organizations_url":"https://api.github.com/users/antw/orgs","repos_url":"https://api.github.com/users/antw/repos","events_url":"https://api.github.com/users/antw/events{/privacy}","received_events_url":"https://api.github.com/users/antw/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/quintel/etengine/milestones/33","html_url":"https://github.com/quintel/etengine/milestones/Deploy%20February%202016","labels_url":"https://api.github.com/repos/quintel/etengine/milestones/33/labels","id":1258132,"number":33,"title":"Deploy February 2016","description":"","creator":{"login":"ChaelKruip","id":1303760,"avatar_url":"https://avatars.githubusercontent.com/u/1303760?v=3","gravatar_id":"","url":"https://api.github.com/users/ChaelKruip","html_url":"https://github.com/ChaelKruip","followers_url":"https://api.github.com/users/ChaelKruip/followers","following_url":"https://api.github.com/users/ChaelKruip/following{/other_user}","gists_url":"https://api.github.com/users/ChaelKruip/gists{/gist_id}","starred_url":"https://api.github.com/users/ChaelKruip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChaelKruip/subscriptions","organizations_url":"https://api.github.com/users/ChaelKruip/orgs","repos_url":"https://api.github.com/users/ChaelKruip/repos","events_url":"https://api.github.com/users/ChaelKruip/events{/privacy}","received_events_url":"https://api.github.com/users/ChaelKruip/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":8,"state":"open","created_at":"2015-08-17T12:16:54Z","updated_at":"2016-01-20T10:55:49Z","due_on":"2016-02-04T23:00:00Z","closed_at":null},"comments":0,"created_at":"2016-01-20T10:55:49Z","updated_at":"2016-01-20T10:55:49Z","closed_at":null,"body":"## Background\r\n\r\nWe have some methods in ET-Engine to calculate the number_of_units attribute based on their <a href=\"https://github.com/quintel/etengine/blob/master/app/models/qernel/converter_api/helper_calculations.rb\">capacity<a/> and one specifically for (space/water heating technologies) <a href=\"https://github.com/quintel/etengine/blob/master/app/models/qernel/demand_driven_converter_api.rb\">demand_driven converters<a/>.\r\n\r\nThere are, however, plenty of converters where a `number_of_units` attributes is wanted, but where these methods return 0. Especially when it comes to scalability and costs, this can even be necessary for other methods to return correct values. For instance in https://github.com/quintel/etsource/issues/800 , we need a `number_of_units` attribute for two car technologies to correctly calculate extra investments costs (otherwise these costs will just be multiplied by 0, the `number_of_units` returned as of now).\r\n\r\n## First attempt\r\n\r\nI simply added a `number_of_units` attribute to `transport_car_using_hydrogen`in ETSource, added this attribute to the list of numeric attributes in <a href=\"https://github.com/quintel/atlas/blob/master/lib/atlas/node.rb\">note.rb<a/> in Atlas, set my Gemlock to my local Atlas in ETEngine and put `V(transport_car_using_hydrogen,number_of_units)` in the GQL sandbox, which worked and gave me the value I had initially put. \r\n\r\n## Problem\r\n\r\nHowever, when I created a new scenario, I got a lot of errors of 'nil cannot be coerced into float' and my dashboard wouldn't appear. Debugging the total cost calculation led me to <a href=\"https://github.com/quintel/etengine/blob/master/app/models/qernel/converter_api/conversion.rb#L146-L147\">conversion.rb<a/> : \r\n````\r\nwhen :converter\r\n      cost * number_of_units\r\n````\r\n I figured this is because ETEngine, now that number_of_units is a converter attribute, looks for it in every converter and returns nil if it is not included in the list of converter attributes. This belief was strengthened by the fact that the error arose in `agriculture_burner_crude_oil`, the first converter given our folder structure.\r\n\r\n## Possible solution\r\n\r\nThe best possible possible solution that came to my mind is the following (however, I don't know how hard it is to implement): make `number_of_units` an 'optional' attribute, such that ETEngine picks it up if it is included in the particular converters attributes, but 'skips' the converter (and doesn't return number_of_units = nil) if it is not there and then executes other `number_of_units` calculations mentioned at the start of this ticket.\r\n\r\nThis solution has the advantage it doesn't require the development of new `number_of_units` calculation methods and that other converters which would benefit from or need a `number_of_units` attributes could easily get one as well.\r\n\r\n@antw , what are your thoughts, do you think this is easily implemented, do you foresee any trouble, or would you perhaps know a better solution (one that allows us to either calculate or define the number_of_units for converters without capacities)?"}}