Skip to content

Commit

Permalink
Merge pull request #1040 from qualand/particle_gen3_csp
Browse files Browse the repository at this point in the history
Particle gen3 csp
  • Loading branch information
qualand authored Jul 28, 2023
2 parents c72cfab + 176703c commit 526b6bd
Show file tree
Hide file tree
Showing 36 changed files with 4,519 additions and 1,220 deletions.
10 changes: 6 additions & 4 deletions solarpilot/Ambient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void Ambient::calcBuieCSRIntensity(std::vector<double>& angle, std::vector<doubl
calculate relative solar intensity over the span 0..angle_max[mrad] at npt increments, filling 'angle' and 'intesity'
Creates the Buie (2003) sun shape based on CSR
[1] Buie, D., Dey, C., & Bosi, S. (2003). The effective size of the solar cone for solar concentrating systems. Solar energy, 74(2003), 417–427.
[2] Buie, D., Monger, A., & Dey, C. (2003). Sunshape distributions for terrestrial solar simulations. Solar Energy, 74(March 2003), 113–122.
[1] Buie, D., Dey, C., & Bosi, S. (2003). The effective size of the solar cone for solar concentrating systems. Solar energy, 74(2003), 417–427.
[2] Buie, D., Monger, A., & Dey, C. (2003). Sunshape distributions for terrestrial solar simulations. Solar Energy, 74(March 2003), 113–122.
*/
double dt_s = .2;
Expand Down Expand Up @@ -353,6 +353,8 @@ void Ambient::calcSpacedDaysHours(double lat, double lon, double tmz, int nday,
DateTime DT;
int month, dom;

if (nday == 1) throw spexception("Algorithm to determine spaced days cannot handle a input of one day.");

for(int i=0; i<nday; i++){
//Calculate the day number - The days are evenly distributed over the cosine wave of the year
uday[i] = 355 - (int)floor(acos(-1.+2.*i/(float)(nday-1))/pi*(float)(355-172));
Expand Down Expand Up @@ -427,7 +429,7 @@ double Ambient::calcInsolation(var_map &V, double /*azimuth*/, double zenith, in
break;
//case Ambient::CONSTANT:
case var_ambient::INSOL_TYPE::CONSTANT_VALUE:
dni = V.sf.dni_des.val / (S0 * 1000.);
dni = V.sf.dni_des.val / (S0 * 1000.); // TODO: Should this be dni_layout? and not dni_des? Or should we just remove dni_layout
break;
//case Ambient::MOON:
case var_ambient::INSOL_TYPE::MOON_MODEL:
Expand All @@ -443,4 +445,4 @@ double Ambient::calcInsolation(var_map &V, double /*azimuth*/, double zenith, in
}
return dni * S0 * 1000.;

}
}
66 changes: 37 additions & 29 deletions solarpilot/AutoPilot_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ bool AutoPilot::Setup(var_map &V, bool /*for_optimize*/)
_SF->PrepareFieldLayout(*_SF, 0, true); //Run the layout method in refresh_only mode
Vect sun = Ambient::calcSunVectorFromAzZen( _SF->getVarMap()->sf.sun_az_des.Val()*D2R, (90. - _SF->getVarMap()->sf.sun_el_des.Val())*D2R );
_SF->calcHeliostatShadows(sun);
double area = V.land.land_area.Val(); //acre
double area = V.land.land_area.Val(); //acre -> TODO (Bill) why is this here?
V.land.bound_area.Setval( area );
V.land.land_area.Setval( area );
}
Expand Down Expand Up @@ -608,8 +608,11 @@ void AutoPilot::GenerateDesignPointSimulations(var_map &V, vector<string> &wdata
day, hour, month, dni, tdry, pres, wspd
1.., 0.., 1-12, W/m2, C, bar, m/s
*/

interop::GenerateSimulationWeatherData(V, -1, wdata);
#ifdef _DEBUG
interop::GenerateSimulationWeatherData(V, var_solarfield::DES_SIM_DETAIL::SINGLE_SIMULATION_POINT, wdata);
#else
interop::GenerateSimulationWeatherData(V, -1, wdata);
#endif
}

void AutoPilot::PreSimCallbackUpdate()
Expand All @@ -628,37 +631,35 @@ void AutoPilot::PreSimCallbackUpdate()
}
}


void AutoPilot::PostProcessLayout(sp_layout &layout)
{
/*
Layout post-process.. collect the layout results and fill the data into the
layout structure for later use
Calculate all post layout parameters
*/
/*
Layout post-process.. collect the layout results and fill the data into the
layout structure for later use
*/

Hvector* hpos = _SF->getHeliostats();
layout.heliostat_positions.clear();
layout.heliostat_positions.reserve(hpos->size());
for (int i = 0; i < (int)hpos->size(); i++) {
sp_layout::h_position hp;
hp.location.x = hpos->at(i)->getLocation()->x;
hp.location.y = hpos->at(i)->getLocation()->y;
hp.location.z = hpos->at(i)->getLocation()->z;
Hvector *hpos = _SF->getHeliostats();
layout.heliostat_positions.clear();
for(int i=0; i<(int)hpos->size(); i++){
sp_layout::h_position hp;
hp.location.x = hpos->at(i)->getLocation()->x;
hp.location.y = hpos->at(i)->getLocation()->y;
hp.location.z = hpos->at(i)->getLocation()->z;

hp.cant_vector.i = hpos->at(i)->getCantVector()->i;
hp.cant_vector.i = hpos->at(i)->getCantVector()->i;
hp.cant_vector.j = hpos->at(i)->getCantVector()->j;
hp.cant_vector.k = hpos->at(i)->getCantVector()->k;

hp.aimpoint.x = hpos->at(i)->getAimPoint()->x;
hp.aimpoint.y = hpos->at(i)->getAimPoint()->y;
hp.aimpoint.z = hpos->at(i)->getAimPoint()->z;
hp.aimpoint.y = hpos->at(i)->getAimPoint()->y;
hp.aimpoint.z = hpos->at(i)->getAimPoint()->z;

hp.focal_length = hpos->at(i)->getFocalX();
hp.template_number = -1;
//hp.user_optics = false;
layout.heliostat_positions.push_back( hp );
}

hp.focal_length = hpos->at(i)->getFocalX();
hp.template_number = -1;
//hp.user_optics = false;
layout.heliostat_positions.push_back(hp);
}

var_map *V = _SF->getVarMap();
_SF->updateAllCalculatedParameters( *V );
Expand Down Expand Up @@ -727,7 +728,7 @@ void AutoPilot::PrepareFluxSimulation(sp_flux_table &fluxtab, int flux_res_x, in
}

fluxtab.flux_surfaces.clear();
//resize the results to accommodate each receiver surface
//resize the results to accommodate each receiver surfaces
int nsurftot=0;
for(int i=0; i<(int)_SF->getReceivers()->size(); i++){
for(int j=0; j<(int)_SF->getReceivers()->at(i)->getFluxSurfaces()->size(); j++){
Expand All @@ -736,8 +737,12 @@ void AutoPilot::PrepareFluxSimulation(sp_flux_table &fluxtab, int flux_res_x, in
}
fluxtab.flux_surfaces.resize(nsurftot);
//resize the flux surfaces to match the flux data and the number of annual simulation positions
for(int i=0; i<nsurftot; i++)
fluxtab.flux_surfaces.at(i).flux_data.resize(flux_res_y, flux_res_x, nflux_sim);
for (int i = 0; i < (int)_SF->getReceivers()->size(); i++) {//for all receivers
for (int j = 0; j < (int)_SF->getReceivers()->at(i)->getFluxSurfaces()->size(); j++) {//for all receiver
FluxSurface *fs = &_SF->getReceivers()->at(i)->getFluxSurfaces()->at(j);
fluxtab.flux_surfaces.at(i+j).flux_data.resize(fs->getFluxNY(), fs->getFluxNX(), nflux_sim); // TODO (Bill): why is the resizing here?
}
}
}

void AutoPilot::PostProcessFlux(sim_result &result, sp_flux_map &fluxmap, int flux_layer)
Expand Down Expand Up @@ -1064,6 +1069,9 @@ bool AutoPilot::CalculateFluxMapsOV1(vector<vector<double> > &sunpos, vector<vec
overload to provide the flux data in a simple 2D vector arrangement. Each flux map is provided
in a continuous sequence, and it is up to the user to separate out the data based on knowledge
of the number of flux maps and dimension of each flux map.
NOTE: This function does not support multiple flux surfaces
This is not used in current production code...
*/

//Call the main algorithm
Expand Down
4 changes: 2 additions & 2 deletions solarpilot/AutoPilot_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SPEXPORT AutoPilot
void PreSimCallbackUpdate();
void SetExternalSFObject(SolarField *SF);
bool Setup(var_map &V, bool for_optimize = false);
void PostProcessLayout(sp_layout& layout);
void PostProcessLayout(sp_layout& layout);
//generate weather data
void GenerateDesignPointSimulations(var_map &V, std::vector<std::string> &hourly_weather_data);
//Simulation methods
Expand All @@ -121,7 +121,7 @@ class SPEXPORT AutoPilot
bool IsSimulationCancelled();
//other
sp_optimize *GetOptimizationObject();

struct API_CANT_TYPE { enum A {NONE, ON_AXIS, EQUINOX, SOLSTICE_SUMMER, SOLSTICE_WINTER }; };

};
Expand Down
51 changes: 25 additions & 26 deletions solarpilot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,31 @@ Project(solarpilot_core)
include_directories(. ../nlopt ../lpsolve .. $ENV{CORETRACEDIR})

set(SOLARPILOT_SRC
Ambient.cpp
API_structures.cpp
AutoPilot_API.cpp
#CoPilot_API.cpp
definitions.cpp
Ambient.cpp Ambient.h
API_structures.cpp API_structures.h
AutoPilot_API.cpp AutoPilot_API.h
definitions.cpp definitions.h
exceptions.hpp
Financial.cpp
Flux.cpp
fluxsim.cpp
heliodata.cpp
Heliostat.cpp
interop.cpp
IOUtil.cpp
Land.cpp
LayoutSimulateThread.cpp
mod_base.cpp
#MultiRecOptimize.cpp
OpticalMesh.cpp
optimize.cpp
Receiver.cpp
SolarField.cpp
solpos.cpp
STObject.cpp
string_util.cpp
STSimulateThread.cpp
Toolbox.cpp)
Financial.cpp Financial.h
Flux.cpp Flux.h
fluxsim.cpp fluxsim.h
heliodata.cpp heliodata.h
Heliostat.cpp Heliostat.h
interop.cpp interop.h
IOUtil.cpp IOUtil.h
Land.cpp Land.h
LayoutSimulateThread.cpp LayoutSimulateThread.h
mod_base.cpp mod_base.h
OpticalMesh.cpp OpticalMesh.h
optimize.cpp optimize.h
Receiver.cpp Receiver.h
SolarField.cpp SolarField.h
solpos.cpp solpos00.h
sort_method.h
STObject.cpp STObject.h
string_util.cpp string_util.h
STSimulateThread.cpp STSimulateThread.h
Toolbox.cpp Toolbox.h)



Expand All @@ -68,7 +67,7 @@ if(MSVC)
endforeach()
else()
if (APPLE)
add_compile_options( -fno-common)
add_compile_options( -fno-common)
add_definitions(-DWX_PRECOMP)
else()
add_definitions(-D__64BIT__)
Expand Down
Loading

0 comments on commit 526b6bd

Please sign in to comment.