Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lpsolve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ if(MSVC)
set(ADD_CFLAGS "${ADD_CFLAGS} /DRoleIsExternalInvEngine /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE")
set(ADD_CFLAGS "${ADD_CFLAGS} /DFPUexception /DNOFORTIFY /D LP_MAXLINELEN=0")
else()
set(ADD_CFLAGS "${ADD_CFLAGS} -Wall -DWX_PRECOMP -DCHECK_SOLUTION -DYY_NEVER_INTERACTIVE -DPARSER_LP
-DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine")
set(ADD_CFLAGS "${ADD_CFLAGS} -Wall -DWX_PRECOMP -DCHECK_SOLUTION -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may cause a conflict with the ORTools branch but we will address when trying to merge that pull request

endif()
set_additional_compile_options(lpsolve ${ADD_CFLAGS})

Expand Down
30 changes: 15 additions & 15 deletions shared/lib_pvshade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ double sssky_diffuse_table::compute(double surface_tilt) {
if (gcr == 0)
throw std::runtime_error("sssky_diffuse_table::compute error: gcr required in initialization");
// sky diffuse reduction
const size_t n_steps = 250;
const size_t n_steps = 250;
double step = 1.0 / (double)n_steps;
double skydiff = 0.0;
double tand_stilt = tand(surface_tilt);
Expand All @@ -314,26 +314,26 @@ double sssky_diffuse_table::compute(double surface_tilt) {
double Asky_shade[n_steps];
for (int n = 0; n < n_steps; n++)
{
if (surface_tilt != 0)
if (surface_tilt != 0) {
arg[n] = (1 / tand_stilt) - (1 / (gcr * sind_stilt * (1 - n * step)));
else
gamma[n] = (-M_PI / 2) + atan(arg[n]);
tan_tilt_gamma[n] = tan(surface_tilt * DTOR + gamma[n]);
Asky_shade[n] = M_PI + M_PI / pow((1 + tan_tilt_gamma[n] * tan_tilt_gamma[n]), 0.5);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Much cleaner!

if ((surface_tilt * DTOR + gamma[n]) > (M_PI / 2))
{
Asky_shade[n] = 2 * M_PI - Asky_shade[n];
}
skydiff += (Asky_shade[n] / Asky) * step;
} else {
arg[n] = std::numeric_limits<double>::quiet_NaN();
gamma[n] = (-M_PI / 2) + atan(arg[n]);
tan_tilt_gamma[n] = tan(surface_tilt * DTOR + gamma[n]);
Asky_shade[n] = M_PI + M_PI / pow((1 + tan_tilt_gamma[n] * tan_tilt_gamma[n]), 0.5);
if (std::isnan(Asky_shade[n]))
{
gamma[n] = std::numeric_limits<double>::quiet_NaN();
tan_tilt_gamma[n] = std::numeric_limits<double>::quiet_NaN();
Asky_shade[n] = Asky;
skydiff += step;
}
else if ((surface_tilt * DTOR + gamma[n]) > (M_PI / 2))
{
Asky_shade[n] = 2 * M_PI - Asky_shade[n];
}
else {}
skydiff += (Asky_shade[n] / Asky) * step;
}
int surface_tilt_key = int(surface_tilt * derates_table_digits_multiplier);
derates_table[surface_tilt_key] = skydiff;
derates_table[surface_tilt_key] = skydiff;
return skydiff;
}

Expand Down