Skip to content

Commit

Permalink
fixing process flux function for cavity
Browse files Browse the repository at this point in the history
  • Loading branch information
qualand committed Oct 18, 2024
1 parent a2364ee commit 964440f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
4 changes: 2 additions & 2 deletions solarpilot/Ambient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void Ambient::calcSunPosition(double lat, double lon, double timezone, double ts


long retcode = 0; //Initialize with no errors
retcode = S_solpos(pdat); //Call the solar posotion algorithm
retcode = S_solpos(pdat); //Call the solar position algorithm
S_decode(retcode, pdat); //Check the return code

//set the calculated values
Expand Down Expand Up @@ -243,7 +243,7 @@ void Ambient::calcDaytimeHours(double hrs[2], double lat, double lon, double tim


long retcode = 0; //Initialize with no errors
retcode = S_solpos(pdat); //Call the solar posotion algorithm
retcode = S_solpos(pdat); //Call the solar position algorithm
//srss( pdat );
S_decode(retcode, pdat); //Check the return code
hrs[0] = pdat->sretr/60.;
Expand Down
9 changes: 9 additions & 0 deletions solarpilot/Receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,15 @@ void FluxSurface::Normalize(){

}

void FluxSurface::Scale(double flux_mult /*-*/) {

for (int i = 0; i < _nflux_x; i++) {
for (int j = 0; j < _nflux_y; j++) {
_flux_grid.at(i).at(j).flux *= flux_mult;
}
}
}

//-----------------Receiver----------------

void Receiver::Create(var_receiver &V, double tht)
Expand Down
1 change: 1 addition & 0 deletions solarpilot/Receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class FluxSurface : public mod_base
//Declare the scripts
void DefineFluxPoints(var_receiver &V, int rec_geom, int nx=-1, int ny=-1);
void Normalize();
void Scale(double flux_mult /*-*/);
void ClearFluxGrid();
void ClearFluxGridResetMaxFlux();
};
Expand Down
2 changes: 1 addition & 1 deletion solarpilot/STObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ bool ST_System::CreateSTSystem(SolarField &SF, Hvector &helios, Vect &sunvect){
}
/*--- Create a virtual stage ---*/

/*--- Set the receiever stages ---*/
/*--- Set the receiver stages ---*/
StageList.push_back(new ST_Stage());
ST_Stage *r_stage = StageList.back();
//Global origin
Expand Down
47 changes: 30 additions & 17 deletions solarpilot/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,12 @@ void interop::GenerateSimulationWeatherData(var_map &V, int design_method, Array
switch (design_method)
{
case var_solarfield::DES_SIM_DETAIL::SUBSET_OF_DAYSHOURS:
//case LAYOUT_DETAIL::SUBSET_HOURS:

{ //Subset of days/hours
//Need to add this still
V.amb.sim_time_step.Setval(0.);
throw spexception("Simulation with a user-specified list of days/hours is not currently supported. Please use another option.");
//break;
}
//case LAYOUT_DETAIL::SINGLE_POINT:
case var_solarfield::DES_SIM_DETAIL::SINGLE_SIMULATION_POINT:
{ //2) Single design point=1;
V.amb.sim_time_step.Setval(0.);
Expand All @@ -201,14 +198,12 @@ void interop::GenerateSimulationWeatherData(var_map &V, int design_method, Array
wdatvar->setStep(0, dom, hour, month, P.dni, P.Tamb, P.Patm, P.Vwind, P.Simweight);
break;
}
//case LAYOUT_DETAIL::NO_FILTER:
case var_solarfield::DES_SIM_DETAIL::DO_NOT_FILTER_HELIOSTATS:
{ //3) Do not filter heliostats=0;
wdatvar->clear();
V.amb.sim_time_step.Setval(0.);
break;
}
//case LAYOUT_DETAIL::FULL_ANNUAL:
case var_solarfield::DES_SIM_DETAIL::ANNUAL_SIMULATION:
{ //4) Annual simulation=3;
*wdatvar = WeatherData(V.amb.wf_data.val); //vset["ambient"][0]["wf_data"].value;
Expand All @@ -217,7 +212,6 @@ void interop::GenerateSimulationWeatherData(var_map &V, int design_method, Array
V.amb.sim_time_step.Setval(3600.);
break;
}
//case LAYOUT_DETAIL::MAP_TO_ANNUAL:
case var_solarfield::DES_SIM_DETAIL::EFFICIENCY_MAP__ANNUAL:
{ //Efficiency map + annual simulation
V.amb.sim_time_step.Setval(3600.);
Expand Down Expand Up @@ -253,8 +247,6 @@ void interop::GenerateSimulationWeatherData(var_map &V, int design_method, Array
break;

}
//case LAYOUT_DETAIL::LIMITED_ANNUAL:
//case LAYOUT_DETAIL::AVG_PROFILES:
case var_solarfield::DES_SIM_DETAIL::LIMITED_ANNUAL_SIMULATION:
case var_solarfield::DES_SIM_DETAIL::REPRESENTATIVE_PROFILES:
case -1: //for optimization
Expand Down Expand Up @@ -2413,22 +2405,43 @@ void sim_result::process_raytrace_simulation(SolarField& SF, sim_params& P, int
}
#endif

void sim_result::process_flux(SolarField *SF, bool normalize){
void sim_result::process_flux(SolarField* SF, bool normalize) {
flux_surfaces.clear();
receiver_names.clear();
int nr = (int)SF->getReceivers()->size();
Receiver *rec;
for(int i=0; i<nr; i++){
Receiver* rec;
for (int i = 0; i < nr; i++) {
rec = SF->getReceivers()->at(i);
if(! rec->isReceiverEnabled() ) continue;
flux_surfaces.push_back( *rec->getFluxSurfaces() );
if(normalize){
for(unsigned int j=0; j<rec->getFluxSurfaces()->size(); j++){
flux_surfaces.back().at(j).Normalize();
if (!rec->isReceiverEnabled()) continue;
int n_surfaces = rec->getFluxSurfaces()->size();
flux_surfaces.push_back(*rec->getFluxSurfaces());
if (normalize) {
if (n_surfaces == 1) {
for (unsigned int j = 0; j < rec->getFluxSurfaces()->size(); j++) {
flux_surfaces.back().at(j).Normalize();
}
}
else {
// For aperture (j = 0), use normalize, because we don't want it to count towards total flux
flux_surfaces.back().at(0).Normalize();

// Sum flux on all receiver panels
double flux_tot = 0.0;
for (unsigned int j = 1; j < rec->getFluxSurfaces()->size(); j++) {
flux_tot += flux_surfaces.back().at(j).getTotalFlux();
}

for (unsigned int j = 1; j < rec->getFluxSurfaces()->size(); j++) {
flux_surfaces.back().at(j).Scale(1.0 / flux_tot);
}
}
}
receiver_names.push_back( SF->getReceivers()->at(i)->getVarMap()->rec_name.val );
receiver_names.push_back(
//*SF->getReceivers()->at(i)->getReceiverName()
SF->getReceivers()->at(i)->getVarMap()->rec_name.val
);
}

}

//------parametric------------------------
Expand Down
2 changes: 1 addition & 1 deletion solarpilot/interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "mod_base.h"
#include "heliodata.h"
#include "definitions.h"
#ifdef SP_USE_THREADS
#ifdef SP_USE_SOLTRACE
#include "stapi.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions ssc/cmod_csp_tower_particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ class cm_csp_tower_particle : public compute_module
// Receiver model
// *********************************************************

// Using cmod inputs as initial guesses for receiver
// Initializing receivers with cmod inputs - these are initial guesses when SolarPILOT optimization is used
double THT = as_double("h_tower"); // [m] tower height
std::vector<double> rec_height = as_vector_double("rec_height"); // [m] receiver height
std::vector<double> rec_width = as_vector_double("rec_width"); // [m] receiver width
Expand Down Expand Up @@ -878,7 +878,7 @@ class cm_csp_tower_particle : public compute_module
else { // Throw error if not running optimization
std::string msg;
msg = util::format("Receiver (%d) failed to converge at design condition. "
"Aperture size is too large.", i);
"Aperture size is most likely too large or receiver parameters are unrealistic.", i);
throw exec_error("csp_tower_particle", msg);
}
}
Expand Down

0 comments on commit 964440f

Please sign in to comment.