{"action":"created","issue":{"url":"https://api.github.com/repos/pvlib/pvlib-python/issues/409","repository_url":"https://api.github.com/repos/pvlib/pvlib-python","labels_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/409/labels{/name}","comments_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/409/comments","events_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/409/events","html_url":"https://github.com/pvlib/pvlib-python/pull/409","id":292112474,"node_id":"MDExOlB1bGxSZXF1ZXN0MTY1NTEzNzQ0","number":409,"title":"ENH: WIP: add methods and tests for a explicit IV curve calculation of single-diode model","user":{"login":"mikofski","id":1385621,"node_id":"MDQ6VXNlcjEzODU2MjE=","avatar_url":"https://avatars1.githubusercontent.com/u/1385621?v=4","gravatar_id":"","url":"https://api.github.com/users/mikofski","html_url":"https://github.com/mikofski","followers_url":"https://api.github.com/users/mikofski/followers","following_url":"https://api.github.com/users/mikofski/following{/other_user}","gists_url":"https://api.github.com/users/mikofski/gists{/gist_id}","starred_url":"https://api.github.com/users/mikofski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikofski/subscriptions","organizations_url":"https://api.github.com/users/mikofski/orgs","repos_url":"https://api.github.com/users/mikofski/repos","events_url":"https://api.github.com/users/mikofski/events{/privacy}","received_events_url":"https://api.github.com/users/mikofski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":76,"created_at":"2018-01-27T11:12:23Z","updated_at":"2018-06-28T07:13:23Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/pvlib/pvlib-python/pulls/409","html_url":"https://github.com/pvlib/pvlib-python/pull/409","diff_url":"https://github.com/pvlib/pvlib-python/pull/409.diff","patch_url":"https://github.com/pvlib/pvlib-python/pull/409.patch"},"body":"pvlib python pull request guidelines\r\n====================================\r\n\r\nThank you for your contribution to pvlib python!\r\n\r\nYou may submit a pull request with your code at any stage of completion, however, before the code can be merged the following items must be addressed:\r\n\r\n - [x] Closes issue #408 \r\n - [x] Fully tested. Added and/or modified tests to ensure correct behavior for all reasonable inputs. Tests must pass on the TravisCI and Appveyor testing services.\r\n - [x] Code quality and style is sufficient. Passes ``git diff upstream/master -u -- \"*.py\" | flake8 --diff`` and/or landscape.io linting service.\r\n - [x] New code is fully documented. Includes sphinx/numpydoc compliant docstrings and comments in the code where necessary.\r\n - [x] Updates entries to `docs/sphinx/source/api.rst` for API changes.\r\n - [x] Adds description and name entries in the appropriate `docs/sphinx/source/whatsnew` file for all changes.\r\n\r\nPlease don't hesitate to ask for help if you're unsure of how to accomplish any of the above. You may delete all of these instructions except for the list above.\r\n\r\nBrief description of the problem and proposed solution (if not already fully described in the issue linked to above):\r\n\r\nHi all,\r\n\r\nI implemented a fast version of the single diode using a damped newton step with pre-calculated derivatives. I think that is probably the main reason for the speedup. This is still a WIP. I still have to implement the `IX`, `IXX`, and the number of points, but I'm confident we will still see the same level of speedup even after those calculations. For the number of points, I'll use [the explicit method that Bishop used in the 1988 paper](https://doi.org/10.1016/0379-6787(88)90059-2), since it's way faster. Also, I've started a generic newton_step method, but I haven't substituted in where I did a lot of copy & paste (_aka_: [WET](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#DRY_vs_WET_solutions)) code.\r\n\r\nAlso, I found that the `v_mp`, `i_mp`, and `p_mp` values were consistently slightly off in the existing method, so in the assertion tests I had to use `i_mp = i_from_v(vmp)` and `v_mp = v_from_i(imp)` where `imp` and `vmp` are the new faster values. I think this is because the faster method finds a slightly higher `pmp` value. Of course you can adjust the tolerance, to get even faster convergence, if you're okay with slightly inaccurate values. The newton step iterates about 4 times. The default tolerance is the min `EPS` of the system, a bit ridiculous, so perhaps lowering it to `1e-5` is better ?\r\n\r\nAlso note that this method so far, **does _not_ depend on SciPy** at all, so perhaps it can pass the minimum python travis ci tests?\r\n\r\nThere is a logging function and a gradient check that we can remove in the final version assuming this is approved. Enjoy!\r\n\r\nIf you run `test_way_faster.py` you can get a flair for the speedup:\r\n<details><pre>\r\nIn [1]: %run pvlib/test/test_way_faster.py\r\nDEBUG:__main__:single diode elapsed time = 0.108363[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000411[s]\r\nDEBUG:__main__:spr_e20_327 speedup = 263.657\r\nDEBUG:__main__:single diode elapsed time = 0.007208[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000314[s]\r\nDEBUG:__main__:fs_495 speedup = 22.9554\r\n</pre><pre>\r\nIn [2]: %run pvlib/test/test_way_faster.py\r\nDEBUG:__main__:single diode elapsed time = 0.00827[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000384[s]\r\nDEBUG:__main__:spr_e20_327 speedup = 21.5365\r\nDEBUG:__main__:single diode elapsed time = 0.008368[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000252[s]\r\nDEBUG:__main__:fs_495 speedup = 33.2063\r\n</pre><pre>\r\nIn [3]: %run pvlib/test/test_way_faster.py\r\nDEBUG:__main__:single diode elapsed time = 0.006553[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000386[s]\r\nDEBUG:__main__:spr_e20_327 speedup = 16.9767\r\nDEBUG:__main__:single diode elapsed time = 0.00638[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000386[s]\r\nDEBUG:__main__:fs_495 speedup = 16.5285\r\n</pre><pre>\r\nIn [4]: %run pvlib/test/test_way_faster.py\r\nDEBUG:__main__:single diode elapsed time = 0.006512[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000348[s]\r\nDEBUG:__main__:spr_e20_327 speedup = 18.7126\r\nDEBUG:__main__:single diode elapsed time = 0.010524[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000345[s]\r\nDEBUG:__main__:fs_495 speedup = 30.5043\r\n</pre><pre>\r\nIn [5]: %run pvlib/test/test_way_faster.py\r\nDEBUG:__main__:single diode elapsed time = 0.00794[s]\r\nDEBUG:__main__:way faster elapsed time = 0.0003[s]\r\nDEBUG:__main__:spr_e20_327 speedup = 26.4667\r\nDEBUG:__main__:single diode elapsed time = 0.007225[s]\r\nDEBUG:__main__:way faster elapsed time = 0.000256[s]\r\nDEBUG:__main__:fs_495 speedup = 28.2227\r\n</pre></details>"},"comment":{"url":"https://api.github.com/repos/pvlib/pvlib-python/issues/comments/400935777","html_url":"https://github.com/pvlib/pvlib-python/pull/409#issuecomment-400935777","issue_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/409","id":400935777,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDkzNTc3Nw==","user":{"login":"mikofski","id":1385621,"node_id":"MDQ6VXNlcjEzODU2MjE=","avatar_url":"https://avatars1.githubusercontent.com/u/1385621?v=4","gravatar_id":"","url":"https://api.github.com/users/mikofski","html_url":"https://github.com/mikofski","followers_url":"https://api.github.com/users/mikofski/followers","following_url":"https://api.github.com/users/mikofski/following{/other_user}","gists_url":"https://api.github.com/users/mikofski/gists{/gist_id}","starred_url":"https://api.github.com/users/mikofski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikofski/subscriptions","organizations_url":"https://api.github.com/users/mikofski/orgs","repos_url":"https://api.github.com/users/mikofski/repos","events_url":"https://api.github.com/users/mikofski/events{/privacy}","received_events_url":"https://api.github.com/users/mikofski/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T07:13:23Z","updated_at":"2018-06-28T07:13:23Z","author_association":"CONTRIBUTOR","body":"Looks like that fixed it (the numpy<1.14 boolean mask issue). So take a look and let me know if you have any more suggestions. I think I ticked off or responded to your list. I tried to refactor a little to make it less confusing, but I'm sure it could be better. Also the doc notes could probably be trimmed or cleaned up, I don't know."}}
{"actor":{"display_login":"mikofski"}}