Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite functions in pv_model #689

Draft
wants to merge 22 commits into
base: dev
Choose a base branch
from
Draft

Conversation

SimonHuette
Copy link
Contributor

resolves #688

I will try to optimize the beam radiation for times close to sunrise or sunset. I will adjust the case distinction of omega1 and omega2, also allowing for smaller intervalls between them. This will be balanced out by multiplying the power with the time difference between omega2 and omega1, thus not creating very high peaks in power outputs in the morning (or evening).
Also, I removed the condition Theta_G < 90°, since that should only result in a negative value of r, which is already accounted for, making it unneccessary.

Please let me know what you think!

@SimonHuette SimonHuette added the code quality Code readability or efficiency is improved label Dec 20, 2023
@SimonHuette SimonHuette added this to the Version 4.0 milestone Dec 20, 2023
@SimonHuette SimonHuette self-assigned this Dec 20, 2023
@@ -333,7 +334,7 @@ final case class PvModel private (
val e0 = 1.000110 +
0.034221 * cos(jInRad) +
0.001280 * sin(jInRad) +
0.000719 * cos(2d * jInRad) +
0.00719 * cos(2d * jInRad) +
Copy link
Member

@sebastian-peter sebastian-peter Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Iqbal, this is 0.000719 with three zeroes. The primary source, Spencer, also states the same. Duffie and Zheng as well. Please check again.

Furthermore, could you add the missing sources I just mentioned to the list of sources in documentation as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Duffie p. 9, where I noticed the 2 zeros only. Can you maybe send me the PDFs of the other books, so I can look it up aswell?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, the fifth edition of Duffie seems to differ from all earlier editions in this point. Given that the cited sources stayed the same and I didn't find any other explanation (and the layout seems broken in this edition for the first time), I assume that the change did not happen on purpose and the number with three zeros is still correct. There should be some more investigations here, though.

Copy link
Member

@sebastian-peter sebastian-peter Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great if we added commentary to the readthedocs documentation regarding this issue, i.e. why we're using the fourth edition and not the fifth. (Extraterrestrial Radiation)

@@ -551,12 +581,12 @@ final case class PvModel private (

if (eDifH.value.doubleValue > 0) {
// if we have diffuse radiation on horizontal surface we have to check if we have another epsilon due to clouds get the epsilon
var epsilon = ((eDifH + eBeamH) / eDifH +
var epsilon = ((eDifH + eBeamH / cos(thetaZInRad)) / eDifH +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Duffie and the original Perez use the formula as before. Where did you find the formula with cos thetaZ again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

@SimonHuette SimonHuette Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my reference (Duffie p. 95f). Note that "I_b,n" is not the beam radiation on a horizontal surface, but rather the beam radiation on a surface normal to the direction of the sun. This can be calculated by dividing the beam radiation on a horizontal surface "I_b" (=eBeamH in code) by cos(ThetaZ). This is also demonstrated in Duffie: example 2.16.2

Copy link
Member

@sebastian-peter sebastian-peter Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need some more investigation here, probably focused on the weather data specification. I_b,n is certainly the "normal beam incidence radiation", which means the radiation in direction of the beam, i.e. on a surface that is exactly facing the sun, as you explained. I_b is certainly the radiationon a horizontal plane (i.e. on earth's surface).
All of this is illustrated by figure 1.8.1 in Duffie (4th ed).
The current source we use, Myers, is not quite clear on this. In Perez 1990 it is clearly stated, though: The "normal incidence direct irradiance" is asked for (formula (1), p. 273).

The question now becomes which type of radiation the weather data sources provide. For ERA5, solar radiation always seems to be specified on a horizontal plane. I have not found the specs for ICON and COSMO yet.

So it seems likely to me that you're right with your assumptions. What should be done now is adapting the formula in documentation (replace E_beamH with E_beamH/cos(theta_Z)). Also it be nice to add a hint for fig. 1.8.1 in Duffie to the source.

# Conflicts:
#	src/main/scala/edu/ie3/simona/model/participant/PvModel.scala
Copy link
Member

@sebastian-peter sebastian-peter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also have two more points regarding documentation (readthedocs):

The link to source for Iqbal.1983 has become invalid. Could you find a new link here (could just be a link to the respective page of the publisher, if nothing else is available)? Also please check all other links.

Also related to literature: Could you also indicate page numbers for each source? This has already been done for some sources, but is missing for others. It can speed up understanding the model a bit.

@@ -473,9 +473,9 @@ class PvModelTest extends Specification {
// 0.244 MJ/m^2 = 67.777778 Wh/m^2
//Beam Radiation on horizontal surface
Irradiation eBeamH = Sq.create(67.777778d, WattHoursPerSquareMeter$.MODULE$)
// 0.769 MJ/m^2 = 213,61111 Wh/m^2
// 0.796 MJ/m^2 = 221,111288 Wh/m^2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a typo we made at some point, so this correction should find its way into the new PvModelSpec as well.

@@ -15,7 +15,7 @@ @Article{Maleki.2017
@MISC{Itaca_Sun,
author = {Itacanet},
title = {The Sun As A Source Of Energy},
howpublished={\url{https://www.itacanet.org/the-sun-as-a-source-of-energy/part-3-calculating-solar-angles/}}
howpublished={\url{https://de.scribd.com/document/455342846/Part-3-Calculating-Solar-Angles-ITACA}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite happy with that. We should find a new source, preferably not a web source that can just disappear at any point in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Code readability or efficiency is improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite function in PV Model
3 participants