Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
- commented out "opt_history"
  • Loading branch information
qualand committed Jul 28, 2023
1 parent 176703c commit f84ec88
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
54 changes: 24 additions & 30 deletions ssc/cmod_csp_tower_particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ class cm_csp_tower_particle : public compute_module
int n_flux_x = 10; // Number of points in the horizontal direction of flux surface
// TODO (Bill): Make these user inputs, if Janna agrees
// - n_flux_y must be greater than the number of troughs in the curtain
// - Add a limit to these values <= 50?

if (field_model_type < 4) {
// Field types 0-3 require solarPILOT
Expand All @@ -801,8 +802,7 @@ class cm_csp_tower_particle : public compute_module
assign("is_optimize", 0); // Turn-off heliostat layout and tower optimization
assign("calc_fluxmaps", 1); // Include flux map calculations
if (field_model_type == 0 && sim_type == 1) { // Optimize design field and tower/receiver geometry
// TODO (Bill): Test if optimization works...
// How receiver area being using in the objective function
// TODO (Bill): Update optimization if cost function change
assign("is_optimize", 1);
}
else if (field_model_type == 3 || sim_type == 2) {
Expand Down Expand Up @@ -845,22 +845,22 @@ class cm_csp_tower_particle : public compute_module
spi.run(weather_reader.m_weather_data_provider); // Runs SolarPILOT

//Optimization iteration history
if (field_model_type == 0) { // is optimize
vector<vector<double> > steps;
vector<double> obj, flux;
spi.getOptimizationSimulationHistory(steps, obj, flux);
size_t nr = steps.size();
if (nr > 0) {
size_t nc = steps.front().size() + 2;
ssc_number_t* ssc_hist = allocate("opt_history", nr, nc); // TODO (Bill): who owns "opt_history"? GUI?
for (size_t i = 0; i < nr; i++) {
for (size_t j = 0; j < steps.front().size(); j++)
ssc_hist[i * nc + j] = (ssc_number_t)steps.at(i).at(j);
ssc_hist[i * nc + nc - 2] = (ssc_number_t)obj.at(i);
ssc_hist[i * nc + nc - 1] = (ssc_number_t)flux.at(i);
}
}
}
//if (field_model_type == 0) { // is optimize
// vector<vector<double> > steps;
// vector<double> obj, flux;
// spi.getOptimizationSimulationHistory(steps, obj, flux);
// size_t nr = steps.size();
// if (nr > 0) {
// size_t nc = steps.front().size() + 2;
// ssc_number_t* ssc_hist = allocate("opt_history", nr, nc); // TODO (Bill): who owns "opt_history"? GUI?
// for (size_t i = 0; i < nr; i++) {
// for (size_t j = 0; j < steps.front().size(); j++)
// ssc_hist[i * nc + j] = (ssc_number_t)steps.at(i).at(j);
// ssc_hist[i * nc + nc - 2] = (ssc_number_t)obj.at(i);
// ssc_hist[i * nc + nc - 1] = (ssc_number_t)flux.at(i);
// }
// }
//}

// Collect the optical efficiency and flux map data
if (field_model_type <= 2) {
Expand Down Expand Up @@ -919,7 +919,7 @@ class cm_csp_tower_particle : public compute_module
// Need to specify:
// 1) reflective area (scale flux map)
// 2) number heliostats for heliostats (tracking parasitics)
// 3) total land area before radiative cooling
// 3) total land area
// 4) tower and receiver dimensions
N_hel = as_number("N_hel");
A_sf = as_number("A_sf_in"); //[m2]
Expand Down Expand Up @@ -967,7 +967,6 @@ class cm_csp_tower_particle : public compute_module
n_steps_fixed = steps_per_hour * (size_t)( (sim_setup.m_sim_time_end - sim_setup.m_sim_time_start)/3600. );
sim_setup.m_report_step = 3600.0 / (double)steps_per_hour; //[s]

#ifndef TESTING
// ***********************************************
// Power cycle
// ***********************************************
Expand Down Expand Up @@ -1061,17 +1060,12 @@ class cm_csp_tower_particle : public compute_module
p_csp_power_cycle->assign(C_pc_Rankine_indirect_224::E_W_DOT_COOLER, allocate("P_cooling_tower_tot", n_steps_fixed), n_steps_fixed);
p_csp_power_cycle->assign(C_pc_Rankine_indirect_224::E_P_COND, allocate("P_cond", n_steps_fixed), n_steps_fixed);
p_csp_power_cycle->assign(C_pc_Rankine_indirect_224::E_P_COND_ITER_ERR, allocate("P_cond_iter_err", n_steps_fixed), n_steps_fixed);

p_csp_power_cycle->assign(C_pc_Rankine_indirect_224::E_ETA_THERMAL, allocate("eta", n_steps_fixed), n_steps_fixed);


//// *********************************************************
//// *********************************************************
//// *********************************************************
//// Now set Type 222 parameters
//// *********************************************************
//// *********************************************************
//// *********************************************************
#ifndef TESTING
// *********************************************************
// Receiver model
// *********************************************************

double A_rec = std::numeric_limits<double>::quiet_NaN(); // TODO: This needs to be calculated

Expand Down Expand Up @@ -2171,7 +2165,7 @@ class cm_csp_tower_particle : public compute_module
for (size_t j = 0; j < rec_n_flux_y; j++) { // for all y flux positions
idx = rec_n_flux_y * n_cols_flux_maps * i + n_cols_flux_maps * j;
flux_maps_for_import[idx] = flux_maps_out[idx] = azi_angle;
flux_maps_for_import[idx] = flux_maps_out[idx + 1] = zen_angle;
flux_maps_for_import[idx + 1] = flux_maps_out[idx + 1] = zen_angle;
size_t flux_map_row;
for (size_t k = 2; k < n_cols_flux_maps; k++) {
flux_map_row = rec_n_flux_y * i + j;
Expand Down
3 changes: 2 additions & 1 deletion ssc/cmod_tcsmolten_salt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,15 @@ class cm_tcsmolten_salt : public compute_module
if (is_optimize)
{
//Optimization iteration history
// TODO (Bill): who owns "opt_history"? GUI? It doesn't appear anywhere...
vector<vector<double> > steps;
vector<double> obj, flux;
spi.getOptimizationSimulationHistory(steps, obj, flux);
size_t nr = steps.size();
if (nr > 0)
{
size_t nc = steps.front().size() + 2;
ssc_number_t* ssc_hist = allocate("opt_history", nr, nc);
ssc_number_t* ssc_hist = allocate("opt_history", nr, nc);
for (size_t i = 0; i < nr; i++) {

for (size_t j = 0; j < steps.front().size(); j++)
Expand Down
6 changes: 3 additions & 3 deletions tcs/csp_solver_pt_sf_perf_interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void C_pt_sf_perf_interp::call(const C_csp_weatherreader::S_outputs &weather, do

for (int j = 0; j < m_n_flux_y; j++) { // for all flux y-points
for (int i = 0; i < m_n_flux_x; i++) { // for all flux x-points
// scaling flux map to absolute power, Solarfield area * field efficiency * DNI / feceiver node area
// scaling flux map to absolute power, Solar field area * field efficiency * DNI / receiver node area
ms_outputs.m_flux_map_out(j, i) *= ms_params.m_A_sf*eta_field/m_A_rec_flux_node*weather.m_beam*1.E-3; //[kW/m2]
}
}
Expand All @@ -356,11 +356,11 @@ void C_pt_sf_perf_interp::call(const C_csp_weatherreader::S_outputs &weather, do
void C_pt_sf_perf_interp::off(const C_csp_weatherreader::S_outputs& weather,
const C_csp_solver_sim_info &sim_info)
{
// Increase call-per-timestep counter
// Increase call-per-time step counter
// Converge() sets it to -1, so on first call this line will adjust it = 0
m_ncall++;

// Get sim info
// Get simulation info
double step = sim_info.ms_ts.m_step;

m_is_field_tracking = false;
Expand Down
2 changes: 1 addition & 1 deletion tcs/ud_power_cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class C_ud_pc_table_generator
double m_dot_htf_ND_ref /*-*/, double m_dot_htf_ND_low /*-*/, double m_dot_htf_ND_high /*-*/, int n_m_dot_htf_ND,
util::matrix_t<double> & T_htf_ind, util::matrix_t<double> & T_amb_ind, util::matrix_t<double> & m_dot_htf_ind);

// Callback funtion
// Callback function
bool(*mf_callback)(std::string &log_msg, std::string &progress_msg, void *data, double progress, int out_type);
void *mp_mf_active;

Expand Down

0 comments on commit f84ec88

Please sign in to comment.