Example.
The following example generates graphs for several locations for the solar radiation received at the ground as if there were no atmosphere.
*********************** Min / Max DLI solar radiation days *********************************************************
/*************/
/* Calculate the dli on the min/max solar radiation days. */
do
{
zoned_sun_time shanghai1 = date::make_zoned("Asia/Shanghai", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time losangeles1 = date::make_zoned("America/Los_Angeles", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time sydney1 = date::make_zoned("Australia/Sydney", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time newyork1 = date::make_zoned("America/New_York", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time moscow1 = date::make_zoned("Europe/Moscow", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time chicago1 = date::make_zoned("America/Chicago", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time newzealand1 = date::make_zoned("Pacific/Auckland", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time quito1 = date::make_zoned("America/Guayaquil", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time Reykjavik = date::make_zoned("Atlantic/Reykjavik", date::local_days{ date::January / 01 / 2018 });
std::vector<sun> sun_info_vec1;
sun sun_element1("Reykjavik, Iceland", 64.135666, -21.862675, Reykjavik);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Shanghai", 31.22222, 121.45806, shanghai1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Los Angeles", 34.052235, -118.243683, losangeles1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Sydney", -33.865143, 151.209900, sydney1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("New York", 40.730610, -73.935242, newyork1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Moscow", 55.751244, 37.618423, moscow1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Chicago", 41.881832, -87.623177, chicago1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Auckland,NZ", -36.848461, 174.763336, newzealand1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Quito, Ecuador", -0.22985, -78.52495, quito1);
sun_info_vec1.push_back(sun_element1);
for (sun sun_element_location : sun_info_vec1)
{
std::cout << "********************************************************************************************************************" << std::endl;
std::cout << "*********************** Min / Max DLI solar Radiation days without Atmosphere **************************************" << std::endl;
std::cout << "********************************************************************************************************************" << std::endl;
Daily_Light dli;
std::list<std::tuple<double, double, double, zoned_sun_time>> rad_map;
zoned_sun_time sun_time = *sun_element_location.zone_time;
std::cout << "Calculating : ";
double distmax = 0;
double distmax_copy = 0;
double distmin_copy = 0;
double distmin = 5000.0;
double julian_last = 0;
for (int day = 0; day < 365; day++)
{
if (day % 5 == 0) std::cout << "." << std::flush;
/* Determine radiation. */
double distance = dli.calculate_dli(sun_time, &sun_element_location, false);
/* Save this information. */
rad_map.push_back(std::tuple<double, double, double, zoned_sun_time>((double)day, distance, sun_element_location.solar_elevation_corrected, sun_time));
if (distance > distmax)
{
distmax = distance;
}
if (distance < distmin)
{
distmin = distance;
}
/* Update the time. */
sun_time = sun_time.get_local_time() + date::days{ 1 };
sun_element_location.set(sun_element_location.name, sun_element_location.observer_latitude, sun_element_location.observer_longitude, sun_time);
}
std::cout << std::endl;
std::cout << "Location : " << sun_element_location.name << std::endl;
distmax_copy = distmax;
int distmax_ceil = ceil(distmax);
distmin_copy = distmin;
int distmin_floor = floor(distmin);
double chart_x_quant = 96.0 / (distmax_ceil - distmin_floor);
/* Plot the chart */
int day_stride = 3;
double yearly_DLI = 0.0; julian_last = 0;
for (std::tuple<double, double, double, zoned_sun_time> element : rad_map)
{
int day = std::get<0>(element);
double distance = std::get<1>(element);
double temp = std::get<2>(element);
zoned_sun_time sun_time_location = std::get<3>(element);
yearly_DLI += distance;
if ((distance) >= (distmax_copy) || (distance) <= (distmin_copy) || (day % day_stride == 0))
{
std::cout << date::format("%b %d %Y", sun_time_location) << " : " << FG_GREEN << std::string(round(((distance) - distmin)*chart_x_quant), '*') << FG_DEFAULT << " : " << FG_YELLOW << distance << FG_DEFAULT;
if ((distance) >= (distmax_copy))
{
std::cout << FG_GREEN << " <-max- DLI (MJ / m^2 day)" << FG_DEFAULT;
}
if ((distance) <= (distmin_copy))
{
std::cout << FG_GREEN << " <-min- DLI (MJ / m^2 day)" << FG_DEFAULT;
}
std::cout << std::endl;
}
}
std::cout << std::endl;
std::cout << "Yearly DLI : " << yearly_DLI << " (MJ / m^2 year)" << std::endl;
rad_map.clear();
}
} while (0);
Produces the following:
and, so onβ¦
In a similar fashion, estimating the DLI taking into account direct beam radiation, diffuse radiation, and the effect of the atmosphere:
/*************/
/* Calculate the dli on the min/max solar radiation days. */
do
{
zoned_sun_time shanghai1 = date::make_zoned("Asia/Shanghai", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time losangeles1 = date::make_zoned("America/Los_Angeles", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time sydney1 = date::make_zoned("Australia/Sydney", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time newyork1 = date::make_zoned("America/New_York", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time moscow1 = date::make_zoned("Europe/Moscow", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time chicago1 = date::make_zoned("America/Chicago", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time newzealand1 = date::make_zoned("Pacific/Auckland", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time quito1 = date::make_zoned("America/Guayaquil", date::local_days{ date::January / 01 / 2018 });
zoned_sun_time Reykjavik = date::make_zoned("GMT", date::local_days{ date::January / 01 / 2018 });
std::vector<sun> sun_info_vec1;
sun sun_element1("Shanghai", 31.22222, 121.45806, shanghai1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Los Angeles", 34.052235, -118.243683, losangeles1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Sydney", -33.865143, 151.209900, sydney1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("New York", 40.730610, -73.935242, newyork1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Moscow", 55.751244, 37.618423, moscow1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Chicago", 41.881832, -87.623177, chicago1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Auckland,NZ", -36.848461, 174.763336, newzealand1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Quito, Ecuador", -0.22985, -78.52495, quito1);
sun_info_vec1.push_back(sun_element1);
sun_element1.set("Reykjavik, Iceland", 64.135666, -21.862675, Reykjavik);
sun_info_vec1.push_back(sun_element1);
for (sun sun_element_location : sun_info_vec1)
{
std::cout << "********************************************************************************************************************" << std::endl;
std::cout << "*********************** Min / Max DLI solar Radiation days with Atmosphere *****************************************" << std::endl;
std::cout << "********************************************************************************************************************" << std::endl;
Daily_Light dli;
std::list<std::tuple<double, double, double, zoned_sun_time>> rad_map;
zoned_sun_time sun_time = *sun_element_location.zone_time;
std::cout << "Calculating : ";
double distmax = 0;
double distmax_copy = 0;
double distmin_copy = 0;
double distmin = 5000.0;
double julian_last = 0;
for (int day = 0; day < 365; day++)
{
if (day % 5 == 0) std::cout << "." << std::flush;
/* Determine radiation. */
double distance = dli.calculate_dli(sun_time, &sun_element_location, true);
/* Save this information. */
rad_map.push_back(std::tuple<double, double, double, zoned_sun_time>((double)day, distance, sun_element_location.solar_elevation_corrected, sun_time));
if (distance > distmax)
{
distmax = distance;
}
if (distance < distmin)
{
distmin = distance;
}
/* Update the time. */
sun_time = sun_time.get_local_time() + date::days{ 1 };
sun_element_location.set(sun_element_location.name, sun_element_location.observer_latitude, sun_element_location.observer_longitude, sun_time);
}
std::cout << std::endl;
std::cout << "Location : " << sun_element_location.name << std::endl;
distmax_copy = distmax;
int distmax_ceil = ceil(distmax);
distmin_copy = distmin;
int distmin_floor = floor(distmin);
double chart_x_quant = 96.0 / (distmax_ceil - distmin_floor);
/* Plot the chart */
int day_stride = 5;
double yearly_DLI = 0.0; julian_last = 0;
for (std::tuple<double, double, double, zoned_sun_time> element : rad_map)
{
int day = std::get<0>(element);
double distance = std::get<1>(element);
double temp = std::get<2>(element);
zoned_sun_time sun_time_location = std::get<3>(element);
yearly_DLI += distance;
if ((distance) >= (distmax_copy) || (distance) <= (distmin_copy) || (day % day_stride == 0))
{
std::cout << date::format("%b %d %Y", sun_time_location) << " : " << FG_GREEN << std::string(round(((distance) - distmin)*chart_x_quant), '*') << FG_DEFAULT << " : " << FG_YELLOW << distance << FG_DEFAULT;
if ((distance) >= (distmax_copy))
{
std::cout << FG_GREEN << " <-max- DLI (MJ / m^2 day)" << FG_DEFAULT;
}
if ((distance) <= (distmin_copy))
{
std::cout << FG_GREEN << " <-min- DLI (MJ / m^2 day)" << FG_DEFAULT;
}
std::cout << std::endl;
}
}
std::cout << std::endl;
std::cout << "Yearly DLI : " << yearly_DLI << " (MJ / m^2 year)" << std::endl;
rad_map.clear();
}
} while (0);