File Exchange

image thumbnail

Two Diode Solar Cell/Panel Model

version (23 KB) by george12thd P
REAL EFFICIENCY through Modelling of Solar panel


Updated 07 May 2010

View License

First of all you should gather the information from your solar panel datasheet/manual:
1)Short Circuit Current
2)Maximum Power Point Current @ STC
3)Open Circuit Voltage
4)Maximum Power Point Voltage @ STC
5)Thermal coefficient of Short Circuit Current
6)Thermal coefficient of Open Circuit Voltage

To model the solar panel there is a function of the form I=f(V).
If you take a look to the math expression you would see some constants and two variables (the global solar irradiation and ambient temperature) which play a role in the function.
The constants are determined from the above information. Use the file "twoDiode.mdl" to calculate them.

What you have now is the I-V characteristic of the solar panel which is depended from solar irradiation and ambient temperature. The I-V characteristic of your solar panel is implemented in the file "solarpanel.mdl". So you double click the model to define the constants and then you see three inputs. 1)global irradiation 2)temperature 3)Voltage. And you get the current.
For example you keep global irradiation and temperature steady and change the voltage from 0 to the open circuit voltage and you get the nice I-V curve that you would see in your datasheet or manual of your solar panel product.

If you want to connect this box with some resistance or a more complex circuit you would get the electrical behaviour of your solar panel.

But in case you are only interested in power I have also uploaded the file "solarpanel_power.mdl" which has only two inputs: 1) global irradiation and 2) temperature. The solar panel is supposed to be working at Maximum Power Point instantaneously all of the time.

Ok now let's see why we got in all this trouble.
Let's say that your panel has a peak performance of 15%. But noone really cares about STC conditions. In case your country is a bit north maybe there not any time in the year where solar irradiation is 1000W/m^2 so your solar panel would never reach this performance. What you really care is the mean performance for your own territory.
This is easy. You simple go to this website:
You get fill a form of where you live and in what inclination you have installed your panels and you get the irradiation that the surface of your panels receive in a hourly basis for all the year. Yes you get 8760 values. And another 8760 values for the temperature.
There you have to play a little bit with Matlab to extract the values from the excel. Use the xlsread(). Don;t worry you only do this once unless you move to a different area or change the inclination of your panels.

Time to get the results.
Use the irradiation and temperature values as inputs and let the Simulink simulate your solar panel for a whole year. As output is the power of your panel at each time. Try to integrate that (use the integration block) and you get the energy that came out of your solar panel in a year period. The energy that was received is the integration of solar irradiation. But this is expressed in W/m^2 so calculate it with your solar panel's area (width x length).
So now the REAL mean efficiency of this solar panel in YOUR specific area of the world is Energy Out/Energy In

I do not know if have been more thorough or less than I should have but I believe this is good way to compare solar panels.
Get the info and calculate the constants from first solar panel and then simulate to get real mean efficiency.
Do the same for the second, third etc solar panel of the market.
Compare the efficiencies and choose the one with the best efficiency!
Be ware that efficiency is not the only factor. A good guarantee of 25years of operation should be preferred than a 20 years guarantee with slightly less performance!

Cite As

george12thd P (2020). Two Diode Solar Cell/Panel Model (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

ali sh

omar asad


sir wat are the paprameters you used cph,ct,ch used in pv module and the circuit is not running sir,not gettin the output,can u tell me wat is the problem in it

Hello sir,
What this parameters cph, ct, ch & cr represent in the solar module which you have uploaded here?

hello ,can any one tell me what this parameters in solar panel module stand for cph,ct,ch and cr

I am currently working on a project where I will simulate a solar system that consists of multiple solar panels. I have designed my own panel on Simulink, but it doesn't seem to work quite well. So I was searching the internet for solutions and I bumped into your "Two Diode Solar Cell/Panel Model" files. I was planning to use the mathematical solutions of your model to create my electrical model.
I downloaded your files and as you have described I tried to use the information I have on my solar panels in the "twoDiode.mdl". But as I try to write 48.8 V for the open-circuit voltage Voc in certain blocks (Gain9, Gain10, Agykles1 and Agykles2), this value is not accepted. I tried putting in smaller numbers and it turns out that Gain9 and Gain10 allow me to write 18.23616, while Agykles1 and Agykles2 allow me to put 17.9957 at maximum. Is there anything that I could do to use the value of 48.8 V in your model?

And when I tried to calculate the parameters using the maximum values I mentioned above, I get the error "Algebraic state in algebraic loop containing 'twoDiode/Subsystem/Rp_block/Sum' computed at time 0 is Inf or NaN. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)."

First of all, thanks for sharing your design. I would also appreciate any help you can give me.

Take care,

Do you have the "solarpanel_power.mdl" file? It is not in your Zip File Content.

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux