Repository navigation
Villalva Algorithm Pull Request - #2878
JFrederico2022 wants to merge 10 commits into
Conversation
Hey @JFrederico2022! 🎉Thanks for opening your first pull request! We appreciate your If AI is used for any portion of this PR, you must vet the content Finally, be sure the PR description includes the PR |
|
@JFrederico2022 pvlib should get only the functions, not the notebook. It has been a while since we discussed that: #2754 (comment) "In pvlib, a calcparams_villalva function would go into pvlib.pvsystem. Code for fitting would go into pvlib.ivtools.sdm in a new module villalva.py" If you want, you can convert the notebook to a python script and add to the Example Gallery. Just start the script name with "plot_" and use docstrings where you want text to appear. |
|
Hello, @cwhanse I updated the docs. Please, let me know if they are all right. Best regards, |
| rows = [] | ||
| rs_values = np.arange(0.0, rs_max + 0.5 * rs_step, rs_step) | ||
|
|
||
| for resistance_series in rs_values: |
There was a problem hiding this comment.
It looks to me that the helper function will operate on a vector rs_values. I think this for loop could go away. I'd set the numpy error state is set to ignore division by zero, then filter the output values to exclude NaN and negative parameters before finding the values at minimum power error.
|
|
||
| References | ||
| ---------- | ||
| .. [1] M. G. Villalva, PhD thesis, Chapter 3 and Appendix A. |
There was a problem hiding this comment.
Can we add a DOI for both of these references?
There was a problem hiding this comment.
Sure! Here are the full references alongside their DOIs:
[1] M. G. Villalva, "Three-phase electronic power converter for a grid-connected photovoltaic system," PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324
[2] M. G. Villalva, J. R. Gazoli, and E. Ruppert Filho, "Comprehensive Approach to Modeling and Simulation of Photovoltaic Arrays," IEEE Transactions on Power Electronics, 2009. DOI: 10.1109/TPEL.2009.2013862
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
|
Hi @JFrederico2022, great initiative! In my opinion, I think it would be nice for your PR to have a corresponding issue which includes a description of what you are adding to pvlib (e.g., what do you see is missing that a PR would add and include sources). That way reviewers and curious people can have a quick outlook of what's happening. |
The issue exists (#2754) but, @JFrederico2022, please tag this in the PR template |
| References | ||
| ---------- | ||
| .. [1] M. G. Villalva, "Three-phase electronic power converter for a grid-connected photovoltaic system," | ||
| PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324 |
There was a problem hiding this comment.
| PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324 | |
| PhD Thesis, Unicamp, 2010. :doi:`10.47749/T/UNICAMP.2010.781324` |
Apply this DOI formatting to calcparams_villalba too.
| PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324 | ||
| .. [2] M. G. Villalva, J. R. Gazoli, and E. Ruppert Filho, | ||
| "Comprehensive Approach to Modeling and Simulation of Photovoltaic Arrays," | ||
| IEEE Transactions on Power Electronics, 2009. DOI: 10.1109/TPEL.2009.2013862 |
There was a problem hiding this comment.
| IEEE Transactions on Power Electronics, 2009. DOI: 10.1109/TPEL.2009.2013862 | |
| IEEE Transactions on Power Electronics, 2009. :doi:`10.1109/TPEL.2009.2013862` |
Same as above.
|
Remember to list the new functions in https://github.com/pvlib/pvlib-python/blob/main/docs/sphinx/source/reference/pv_modeling/sdm.rst?plain=1 |
There was a problem hiding this comment.
I have suggested a few basic docstring revisions. You can implement changes recommended by reviewers either by committing them individually or, under the Files changed tab, adding the suggestions to a batch and committing them all at once.
Happy to look more in depth at the core implementation in the coming days
| The dimensionless diode ideality factor :math:`n` is supplied by the user. The | ||
| modified ideality factor at reference conditions is calculated as |
There was a problem hiding this comment.
| The dimensionless diode ideality factor :math:`n` is supplied by the user. The | |
| modified ideality factor at reference conditions is calculated as | |
| The dimensionless diode ideality factor :math:`n` is supplied by the user. | |
| The modified ideality factor at reference conditions is calculated as |
| Villalva's basic parameter-extraction method increments the series | ||
| resistance from zero. For each candidate :math:`R_s`, the corresponding | ||
| :math:`R_{sh}`, :math:`I_L`, and :math:`I_0` are calculated and the | ||
| maximum power of the resulting single-diode model is evaluated. The | ||
| selected solution minimizes the absolute difference between modeled and | ||
| reference maximum power. |
There was a problem hiding this comment.
| Villalva's basic parameter-extraction method increments the series | |
| resistance from zero. For each candidate :math:`R_s`, the corresponding | |
| :math:`R_{sh}`, :math:`I_L`, and :math:`I_0` are calculated and the | |
| maximum power of the resulting single-diode model is evaluated. The | |
| selected solution minimizes the absolute difference between modeled and | |
| reference maximum power. | |
| Villalva's parameter-extraction method is described in [1]_ and [2]. This | |
| approach increments the series resistance from zero. For each candidate | |
| :math:`R_s`, the corresponding :math:`R_{sh}`, :math:`I_L`, and :math:`I_0` | |
| are calculated and the maximum power of the resulting single-diode | |
| model is evaluated. The selected solution minimizes the absolute | |
| difference between modeled and reference maximum power. |
| cells_in_series : int | ||
| Effective number of cells or junctions connected in series. | ||
| diode_factor : float | ||
| Dimensionless diode ideality factor used by the Villalva model. |
There was a problem hiding this comment.
| Dimensionless diode ideality factor used by the Villalva model. | |
| Dimensionless diode ideality factor. [unitless] |
| temp_ref : float, default 25 | ||
| Reference cell temperature. [°C] | ||
| irrad_ref : float, default 1000 | ||
| Reference irradiance. [W/m²] |
There was a problem hiding this comment.
| Reference irradiance. [W/m²] | |
| Reference irradiance. [Wm⁻²] |
| References | ||
| ---------- | ||
| .. [1] M. G. Villalva, "Three-phase electronic power converter for a grid-connected photovoltaic system," | ||
| PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324 | ||
| .. [2] M. G. Villalva, J. R. Gazoli, and E. Ruppert Filho, | ||
| "Comprehensive Approach to Modeling and Simulation of Photovoltaic Arrays," | ||
| IEEE Transactions on Power Electronics, 2009. DOI: 10.1109/TPEL.2009.2013862 | ||
| """ |
There was a problem hiding this comment.
@echedey-ls's suggestion to use the :doi sphinx role is correct but these lines are also >79 characters so will fail the flake8 checks. I am unsure why the failure isn't already marked in the diff. The references are also missing some bibliographic information (eg pages/volume), which need to be included in the IEEE format. I recommend the following:
| References | |
| ---------- | |
| .. [1] M. G. Villalva, "Three-phase electronic power converter for a grid-connected photovoltaic system," | |
| PhD Thesis, Unicamp, 2010. DOI: 10.47749/T/UNICAMP.2010.781324 | |
| .. [2] M. G. Villalva, J. R. Gazoli, and E. Ruppert Filho, | |
| "Comprehensive Approach to Modeling and Simulation of Photovoltaic Arrays," | |
| IEEE Transactions on Power Electronics, 2009. DOI: 10.1109/TPEL.2009.2013862 | |
| """ | |
| References | |
| ---------- | |
| .. [1] M. G. Villalva, "Conversor eletrônico de potência trifásico para | |
| sistema fotovoltaico conectado à rede elétrica," Ph.D. dissertation, | |
| Faculdade de Engenharia Elétrica e de Computação, Universidade Estadual | |
| de Campinas (UNICAMP), Campinas, Brazil, 2010. | |
| :doi:`10.47749/T/UNICAMP.2010.781324` | |
| .. [2] M. G. Villalva, J. R. Gazoli, and E. Ruppert Filho, "Comprehensive | |
| approach to modeling and simulation of photovoltaic arrays," IEEE Trans. | |
| Power Electron., vol. 24, no. 5, pp. 1198-1208, May 2009. | |
| :doi:`10.1109/TPEL.2009.2013862` | |
| """ |
| return tracking_data | ||
|
|
||
| def calcparams_villalva( | ||
| effective_irradiance, |
There was a problem hiding this comment.
Two blank lines needed for flake8
| return tracking_data | |
| def calcparams_villalva( | |
| effective_irradiance, | |
| return tracking_data | |
| def calcparams_villalva( | |
| effective_irradiance, |
| Parameters | ||
| ---------- | ||
| effective_irradiance : numeric | ||
| Effective irradiance converted to photocurrent. [W/m²] |
There was a problem hiding this comment.
You can format like this throughout the docs
| Effective irradiance converted to photocurrent. [W/m²] | |
| Effective irradiance converted to photocurrent. [Wm⁻²] |
| best_idx = history["abs_power_error"].idxmin() | ||
| best = history.loc[best_idx] | ||
|
|
||
| print(f"Best R_s = {best['R_s']:.6f} ohm") |
There was a problem hiding this comment.
false positive flake8 failure, I think. Don't add a space here (or on any of the other instances)
|
|
||
| from pvlib.ivtools.sdm.villalva import ( # noqa: F401 | ||
| _villalva_params_at_rs, | ||
| fit_villalva, | ||
| ) |
There was a problem hiding this comment.
Fix the flake8 error by adding a space. I don't think we need to list the private helper here either
| from pvlib.ivtools.sdm.villalva import ( # noqa: F401 | |
| _villalva_params_at_rs, | |
| fit_villalva, | |
| ) | |
| from pvlib.ivtools.sdm.villalva import ( # noqa: F401 | |
| _villalva_params_at_rs, | |
| ) |
docs/sphinx/source/referencefor API changes.docs/sphinx/source/whatsnewfor all changes. Includes link to the GitHub Issue with:issue:`num`or this Pull Request with:pull:`num`. Includes contributor name and/or GitHub username (link with:ghuser:`user`).remote-data) and Milestone are assigned to the Pull Request and linked Issue.