Skip to content

Villalva's Algorithm for SDM-5P Electric Parameters Extraction Model and OPC Parameters Estimation #2754

Open

Description

@JFrederico2022

Hello, everyone!

I'd like to propose the implementation of Villalva's Algorithm for extracting the five-parameter Single-Diode Model (SDM-5P) electrical parameters, including a calc_parameters function compatible with Operational Conditions (OPC).

This algorithm was published in 2009 in IEEE Transactions on Power Electronics and provides a robust iterative method for determining an effective combination of SDM-5P parameters for I-V curve modeling, not restricted to Standard Test Conditions (STC), but applicable to arbitrary OPC.

Notably, the paper has accumulated over 6,000 citations in the literature (source: Google Scholar), reflecting its widespread adoption and relevance to the photovoltaic modeling community.

Image

The full paper is attached below for reference:

Comprehensive Approach to Modeling and Simulation of Photovoltaic Arrays (Villalva et al., 2009)

The algorithm that I'm working is attached here:

Villalva Algorithm for Python.ipynb

I'd really appreciate your help. Thanks in advance and let's discuss!

Best regards,
João Frederico

Activity

  1. RDaxini commented on May 15, 2026

    @RDaxini
    Member

    Some initial thoughts:

    I had a brief review of the paper and I think in principle this would be a valuable addition to pvlib.

    I am not sure yet where this would best fit. I think I need some clarification. I thought the paper was proposing a new iterative method to determine diode parameters, as well as new physical representations/equations of the parameters themselves. In the example though, you just use pvsystem.calcparams_desoto, so I am not sure I understood the paper correctly.

    In terms of the (new) equations, for context, I am curious of the origin of Equation 7. I understand the paper validates it as part of the analysis, but it seems to pop up out of nowhere as a proposed alternative. I might just be lacking some knowledge of different representations of I0 though and maybe this is a common/well-known equation. Anyway, we'd need to make sure we document these equations clearly in the docs.

    One point on notation, we usually try to replicate what a manuscript does, but I think since everywhere else we use I_L for the photocurrent, the use of I_pv might be confusing. I would vote to stick with I_L but make a clear note in the docs that the manuscript uses I_pv.

    if you're feeling ambitious, beyond adding new functions to pvlib it would be a bonus if we could get an example gallery addition as well. Since the modules in the manuscript must be pretty old, an example gallery addition fitting a few newer modules (maybe something from here?) could be valuable.

  2. cwhanse commented on May 15, 2026

    @cwhanse
    Member

    I agree with @RDaxini comments.

    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

    I recall looking at this algorithm some years back and didn't pursue it because we were interested in the commercialized single diode models (PVsyst, CEC). As @RDaxini points out, Eq. 7 creates a new single diode model (single diode equation + all-sky condition equations).

    I'd like to see some additional verification of this algorithm. If we 1) assume parameter values for the single diode equation at STC, cells in series and temperature coefficients, 2) use pvlib.pvsystem.singlediode to calculate Vmp, Imp etc., and 3) apply Villalva's algorithm to the calculated Vmp, Imp, etc., do we recover the starting single diode equation parameters? I tried that in the iPython notebook and it looks like the resistances could be quite different from the assumed parameter values, but I may have made mistakes.

  3. JFrederico2022 commented on May 19, 2026

    @JFrederico2022
    Author

    Hello @RDaxini and @cwhanse! Thanks for the comments. I'll gonna work on these topics.

    I implemented the pvsystem.calcparams_desoto just to certify the determined parameters by the Villalva's model gives the SDM Parameters under OPC. I'll complete that application to Villalva's equations and show that can reproduce the IV curve key points.

    I agree with @RDaxini about we use the standard nominations used by the pvlib community and we can just put a note that in the original paper use different notes for the electric parameters of SDM.

    I think that is a great idea to provide an example in the example gallery. We can work on this.

    @cwhanse is right! The equation is adapted for different conditions, despite it would be simpler to estimate Io under different temperature levels.

    About the algorithm's verification mentioned by @cwhanse, it worked to make the modeling of IV curve and recover the starting SDM equation parameters. I'll organize better the code and bring it here more further to show you step-by-step.

    Again, I really appreciate the interest and the comments to help to improve this algorithm.

  4. markcampanelli commented on May 19, 2026

    @markcampanelli
    Contributor

    @JFrederico2022 One question I have about Villalva et al.'s derivation is equation (6). In equation (13) of the online version of Effective Irradiance Ratios to Improve I–V Curve Measurements and Diode Modeling Over a Range of Temperature and Spectral and Total Irradiance, I derived an expression for the reverse saturation current at the reference (aka. nominal) condition, ID0, that uses the non-ideal single-diode model instead of the idealized model, and it is parameterized in terms of Isc0 and Voc0 (both at reference conditions), where the photocurrent is eliminated as well. I am not sure of the effect of using the ideal approximation (might be bad for degraded devices?), but I never saw the value in applying a numerical approximation when it is seemingly not required. Instead of using equation (8) in my paper for ID (not at reference conditions), equation (13) could be altered to adjust Voc and Isc away from their reference conditions by following Villalva et al. I would be happy to help evaluate if this alternative approach provides any benefit. I have lots of code set up in pvfit for evaluating SDM fits against IEC 61853-1 datasets.

  5. cwhanse commented on May 19, 2026

    @cwhanse
    Member

    @markcampanelli I am not disregarding the technical merits of your idea regarding the saturation current. But we need to trace algorithms to references, and I'm a bit concerned about being able to do that if the implementation mixes equations from Villalva's and your papers. What would we call the resulting function?

    For this traceability, I think it would be best to first implement Villalva as written, and then consider if a variant (with a different name) is an improvement.

  6. adriesse commented on May 20, 2026

    @adriesse
    Member

    I think it would be best to first implement Villalva as written, and then consider if a variant (with a different name) is an improvement.

    I do agree with @cwhanse, but at the same time want to explicitly encourage constructive collaboration. This github may not be the ideal place for it, but I don't know any other!

  7. markcampanelli commented on May 20, 2026

    @markcampanelli
    Contributor

    @cwhanse @adriesse Fair enough. @JFrederico2022 I can investigate this independently, but please do consider this an open invitation to collaborate. More generally, I am interested in the IEC 61853-1 matrix fit quality of different choices for the so-called "auxiliary equations" that produce the full SDM from the standard 5-parameter SDE. BTW, the AEs I typically use in PVfit are at https://pvfit.app/sdm/info/.

  8. RDaxini commented on May 21, 2026

    @RDaxini
    Member

    Especially since this is João's first contribution, and it's a relatively complex one for a first contribution, let's agree on a clear plan forward for João. If I have understood the discussion correctly, @JFrederico2022, this is what I think needs to be done:

    1. Perform some basic additional validation as described here, work with @markcampanelli for assistance
    2. Pending validation, implement a calcparams_villalva() function into pvlib.pvsystem, and fitting code into a new module villalva.py in pvlib.ivtools.sdm
    3. Generate an example gallery addition demonstrating the use of the Villalva algorithm (we should do this anyway even if the implementation faces any setback e.g. with the additional validation). Functions from here could potentially be refactored into pvlib as described in 2. at a later date anyway.
    4. Reach out to @markcampanelli for possible collaboration!
  9. JFrederico2022 commented on May 21, 2026

    @JFrederico2022
    Author

    Hello, everyone.

    Thank you all for the warm engagement. I'm happy to take this discussion further.

    @markcampanelli I'm glad you're interested in a potential collaboration, let's make it happen! I have some ideas for improving the Villalva model across a range of irradiance levels and PV cell temperatures, which could make the modeling more precise under real operating conditions. The IEC 61853-1 matrix fit is a great direction to explore alongside the Villalva model.

    That said, I'd like to prioritize getting the original implementation published in pvlib first, so we have a better foundation to build on for future work.

    @RDaxini thank you for the clear guidelines; they've been very helpful in organizing the workflow.

  10. RDaxini commented on May 22, 2026

    @RDaxini
    Member

    Thanks @JFrederico2022, sounds good.
    If you require any assistance or have any questions about the GitHub mechanics of contributions (forks, branches, pull requests, commits, etc.) then our contributing guide may provide some guidance, but you can also just ask us directly.

  11. dgowdaan-cmyk commented on Jul 2, 2026

    @dgowdaan-cmyk
    Contributor

    Thanks @JFrederico2022 for proposing this. Villalva’s algorithm would be a valuable addition for SDM-5P modeling under OPC.
    I’ve reviewed the 2009 paper and the attached notebook, and I agree with @cwhanse that implementing calcparams_villalva in pvlib.pvsystem plus the fitting code in pvlib.ivtools.sdm.villalva.py makes sense.
    I’d be happy to help with:
    Writing unit tests to verify parameter recovery against singlediode at STC.
    Adding an example gallery entry using newer module data.
    Drafting the docstrings and equation documentation following pvlib conventions.
    Let me know if I can take on the test/example part while the core implementation is developed.

  12. RDaxini commented on Aug 10, 2026

    @RDaxini
    Member

    Thanks @JFrederico2022 for proposing this. Villalva’s algorithm would be a valuable addition for SDM-5P modeling under OPC. I’ve reviewed the 2009 paper and the attached notebook, and I agree with @cwhanse that implementing calcparams_villalva in pvlib.pvsystem plus the fitting code in pvlib.ivtools.sdm.villalva.py makes sense. I’d be happy to help with: Writing unit tests to verify parameter recovery against singlediode at STC. Adding an example gallery entry using newer module data. Drafting the docstrings and equation documentation following pvlib conventions. Let me know if I can take on the test/example part while the core implementation is developed.

    My understanding from recent conversations with JFrederico2022 are that he will handle this in the near future once his grad school schedule permits.

  13. JFrederico2022 commented on Sep 29, 2026

    @JFrederico2022
    Author

    Hello everyone,

    Please find below the Villalva’s IV Curve fitting algorithm, which allows the user to select the ideality factor, and its SDM calc_parameters algorithm under OPC.

    Villalva_Algorithm_Basic_pvlib-python_proposal_and_validation.ipynb

    As a reference, I utilized the organization of the pvlib’s documentation, drawing inspiration from its examples and API references derived from De Soto’s model.

    Additionally, I took into account the validation procedure recommended by @cwhanse. I trust that the code provided is functional.

    Please let me know if the algorithm is satisfactory as it stands and if any adjustments are necessary.

    Best regards,
    João Frederico

  14. cwhanse commented on Sep 29, 2026

    @cwhanse
    Member

    @JFrederico2022 the workbook looks really good. Thanks for adding the round-trip validation.

    Feel free to submit the new functions to pvlib. I'd structure tests around the validation example you show in the workbook: archive the extracted parameters and use the test to recompute them and show they match, and test calcparams_villalva at a few conditions (including some nan) where the known result comes from the jupyter notebook. It's not strictly independent but that's the best we can practically do, I think.

    There's some minor style editing I'd suggest for the docstrings but we can handle that in the PR review.

  15. RDaxini commented on Sep 29, 2026

    @RDaxini
    Member

    Thank you for putting that notebook together @JFrederico2022. I had a scan through as well and I agree with @cwhanse; I don't have anything to add beyond what he has said already. I look forward to reviewing your pull request!

  16. cwhanse commented on Oct 4, 2026

    @cwhanse
    Member

    @JFrederico2022 Looking through the notebook more carefully, I see that diode_factor is an input to the fitting function, which passes it through to the output. So the Villalva method fits only 4 parameters (I_L_ref, I_o_ref, R_sh_ref and R_s) - is that correct? Or are we missing a piece?

  17. JFrederico2022 commented on Oct 6, 2026

    @JFrederico2022
    Author

    @cwhanse Yes, that's correct. In the basic version of Villalva's algorithm implemented in the notebook, the diode ideality factor is provided as an input. Therefore, for a fixed diode_factor, the algorithm determines the other four SDM parameters: I_L_ref, I_o_ref, R_sh_ref, and R_s. The corresponding a_ref is then calculated from the specified diode factor, number of cells in series, reference temperature and thermal voltage.

    There is also an extended version of the approach in which the diode factor can be included in the optimization. In that case, an outer loop searches over candidate values of the diode factor, and for each candidate the inner Villalva procedure determines R_s, R_sh_ref, I_L_ref, and I_o_ref. The best overall parameter set is then selected according to the fitting criterion.

    We could add this version as an optional fitting mode, allowing the user to specify the diode-factor search range and resolution (for example, the minimum and maximum values and the step size). This would allow the algorithm to effectively fit all five SDM parameters instead of requiring the diode factor as a fixed input.

  18. cwhanse commented on Oct 7, 2026

    @cwhanse
    Member

    @JFrederico2022 if there's a reference for the extended version, I think it would be good to include that capability. Having the option to search through diode factors makes this algorithm comparable to the other SDM estimators (return full set of coefficients for a SDM).

    There are other methods for getting a diode factor independently (e.g., slope of a regression between log(irradiance) and Voc), so I also like the implementation that allows for imposing a diode factor.

    Extending to include searching for the diode factor could be in a follow-on PR to avoid substantial scope creep here.

    The primary gap remaining in this PR (as is) is to add some tests. Let me know if you'd like guidance or help with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions