Skip to content

Commit 4b06743

Browse files
committed
debugging and fix compiler warnings in optical model
1 parent 824ff51 commit 4b06743

File tree

6 files changed

+37
-39
lines changed

6 files changed

+37
-39
lines changed

app/project.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ bool Project::O()
17911791
od.m_wc_results = wc.m_results;
17921792
od.m_solar_data = wc.m_solution_data;
17931793
od.m_settings.annual_profit_per_kwh = (
1794-
wc.m_settings.profit_per_kwh / wc.m_settings.annual_multiplier
1794+
wc.m_settings.profit_per_kwh / wc.m_settings.annual_rev_multiplier
17951795
);
17961796
//use a one-year warmup period, or half a year if the sim length is one year.
17971797
if (m_parameters.finance_period.as_integer() > 1)

liboptical/optical_degr.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void optical_degradation::simulate(bool(*callback)(float prg, const char *msg),
212212

213213
//scale the problem
214214
int n_helio_s, t_cycle, sim_hr;
215-
size_t period_idx;
215+
size_t period_idx = 0;
216216
double wash_units_per_hour_s;
217217
//double problem_scale = 1.;
218218
//double hscale = 250.;
@@ -351,19 +351,19 @@ void optical_degradation::simulate(bool(*callback)(float prg, const char *msg),
351351

352352
//update the crew schedule only if the number of crews changes
353353
if (n_active_crews != (size_t)m_wc_results.num_crews_by_period[period_idx])
354-
for (size_t c = 0; c < m_settings.n_wash_crews; c++)
354+
for (size_t crew_idx = 0; crew_idx < m_settings.n_wash_crews; crew_idx++)
355355
{
356-
if (c < n_active_crews)
356+
if (crew_idx < n_active_crews)
357357
{
358-
crews.at(c).is_active = true;
359-
crews.at(c).start_heliostat = m_wc_results.solution_assignments[period_idx].at(c);
360-
crews.at(c).end_heliostat = m_wc_results.solution_assignments[period_idx].at(c+1);
358+
crews.at(crew_idx).is_active = true;
359+
crews.at(crew_idx).start_heliostat = (int)m_wc_results.solution_assignments[period_idx].at(crew_idx);
360+
crews.at(crew_idx).end_heliostat = (int)m_wc_results.solution_assignments[period_idx].at(crew_idx +1);
361361
}
362362
else
363363
{
364-
crews.at(c).is_active = false;
365-
crews.at(c).hours_today = 0.;
366-
crews.at(c).hours_this_week = 0.;
364+
crews.at(crew_idx).is_active = false;
365+
crews.at(crew_idx).hours_today = 0.;
366+
crews.at(crew_idx).hours_this_week = 0.;
367367
}
368368
}
369369
}
@@ -548,7 +548,7 @@ void optical_degradation::simulate(bool(*callback)(float prg, const char *msg),
548548

549549

550550
//fill in the return data
551-
int replacements_made = 0;
551+
float replacements_made = 0.;
552552
for (size_t s = 0; s < crews.size(); s++)
553553
{
554554
//hours_worked += crews.at(s).hours_worked;
@@ -567,13 +567,13 @@ void optical_degradation::simulate(bool(*callback)(float prg, const char *msg),
567567

568568
for (int i = 0; i<m_settings.n_hr_sim; i++)
569569
{
570-
float s = soil.at(i);
571-
float d = degr.at(i);
570+
float s = (float)soil.at(i);
571+
float d = (float)degr.at(i);
572572

573573
m_results.soil_schedule[i] = s;
574574
m_results.degr_schedule[i] = d;
575-
m_results.repl_schedule[i] = repr.at(i);
576-
m_results.repl_total[i] = repr_cum.at(i);
575+
m_results.repl_schedule[i] = (float)repr.at(i);
576+
m_results.repl_total[i] = (float)repr_cum.at(i);
577577

578578
m_results.avg_degr += d;
579579
m_results.avg_soil += s;

liboptical/wash_opt.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void WashCrewOptimizer::ReadSolarDataFromFiles()
115115
m_solar_data.y_pos = y;
116116
m_solar_data.mirror_output = output;
117117
m_solar_data.num_mirrors_by_group = mirrors_by_group;
118-
m_solar_data.num_mirror_groups = mirrors_by_group.size();
118+
m_solar_data.num_mirror_groups = (int)mirrors_by_group.size();
119119
}
120120

121121
void WashCrewOptimizer::ReadWeatherData()
@@ -235,9 +235,10 @@ void WashCrewOptimizer::ReadInputsFile()
235235
m_settings.system_efficiency = inputs["system_efficiency"];
236236
m_settings.num_years = inputs["num_years"];
237237
m_settings.price_per_kwh = inputs["price_per_kwh"];
238-
m_settings.max_num_crews = inputs["max_num_crews"];
238+
m_settings.max_num_crews = (int)inputs["max_num_crews"];
239239
m_settings.heliostat_size = inputs["helio_size"];
240-
m_settings.soiling_rate = inputs["soiling_rate"];
240+
LinearSoilingFunc f(inputs["soiling_rate"] / 24.);
241+
m_func = &f;
241242
m_settings.seasonal_cost_multiple = inputs["seasonal_multiple"];
242243

243244
}
@@ -407,7 +408,7 @@ void WashCrewOptimizer::GroupSolutionMirrors(int hours)
407408
(provided as input) to wash once.
408409
*/
409410
m_solution_data = solar_field_data();
410-
m_solution_data.scale = hours * (m_settings.wash_rate / m_settings.heliostat_size);
411+
m_solution_data.scale = (int)(hours * (m_settings.wash_rate / m_settings.heliostat_size));
411412
m_solution_data.groupings.clear();
412413
for (int t = 0; t < m_settings.periods.size(); t++)
413414
m_results.solution_assignments[t] = {};
@@ -456,7 +457,7 @@ void WashCrewOptimizer::GroupSolutionMirrors(int hours)
456457

457458
//Create a vector consisting of all the elemnents of the set
458459
//(which are unique and ordered).
459-
m_solution_data.num_mirror_groups = assignment_breaks.size() - 1;
460+
m_solution_data.num_mirror_groups = (int)assignment_breaks.size() - 1;
460461
std::vector<double> x(m_solution_data.num_mirror_groups, 0);
461462
std::vector<int> y(m_solution_data.num_mirror_groups, 0);
462463
m_solution_data.num_mirrors_by_group.assign(y.begin(), y.end());
@@ -465,7 +466,7 @@ void WashCrewOptimizer::GroupSolutionMirrors(int hours)
465466
m_solution_data.x_pos.assign(x.begin(), x.end());
466467
m_solution_data.y_pos.assign(x.begin(), x.end());
467468
int idx = 0;
468-
int m;
469+
int m = 0;
469470
for (int c : assignment_breaks)
470471
{
471472
if (c != 0)
@@ -501,11 +502,12 @@ void WashCrewOptimizer::GroupSolutionMirrors(int hours)
501502
cumulative_mirrors += solar_mirrors;
502503
solution_mirrors -= solar_mirrors;
503504
solar_data_idx++;
505+
if (solar_data_idx < m_solar_data.num_mirror_groups)
504506
solar_mirrors = m_solar_data.num_mirrors_by_group[solar_data_idx];
505507
}
506508
}
507509
m_solution_data.mirror_output[solution_idx] = sol_group_output;
508-
for (size_t t = 0; t < m_settings.periods.size() - 1; t++)
510+
for (int t = 0; t < (int)m_settings.periods.size() - 1; t++)
509511
{
510512
if (
511513
std::find(
@@ -538,9 +540,7 @@ void WashCrewOptimizer::CalculateRevenueAndCosts()
538540
/*
539541
Calculates the NPV of the revenue generated per heliostat, as well as the
540542
NPV of the cost per crew, according to the settings and solar data
541-
provided as input. Revenue per mirror and cost per crew are stored in
542-
m_settings.revenuw_per_mirror and m_settings.total_cost_per_crew,
543-
respectively.
543+
provided as input.
544544
*/
545545
double annual_labor_cost = (
546546
m_settings.hourly_cost_per_crew * m_settings.crew_hours_per_week * (365./7.)
@@ -574,6 +574,8 @@ void WashCrewOptimizer::CalculateRevenueAndCosts()
574574
* m_settings.operating_margin * revenue_multiplier
575575
);
576576

577+
m_settings.annual_rev_multiplier = revenue_multiplier; //used later in optical simulation
578+
577579
}
578580

579581
void WashCrewOptimizer::AssignSoilingFunction(SoilingFunction *func)
@@ -651,7 +653,7 @@ double WashCrewOptimizer::GetAssignmentCost(int i, int j)
651653
double mirrors_per_hour = (m_settings.wash_rate / m_settings.heliostat_size);
652654
double time = GetNumberOfMirrors(i, j) * (168. / m_settings.crew_hours_per_week) / mirrors_per_hour; //in hours between cleanings
653655

654-
return m_settings.profit_per_kwh * total_output * m_func->Evaluate(time);// + m_settings.total_cost_per_crew;
656+
return m_settings.profit_per_kwh * total_output * m_func->Evaluate(time);
655657
}
656658

657659
double WashCrewOptimizer::EvaluatePath(std::vector<int> path)
@@ -743,7 +745,7 @@ std::vector<int> WashCrewOptimizer::GetEqualAssignmentPath(int num_crews)
743745
std::vector<int> path = {0};
744746
for (int j = 1; j <= num_crews; j++)
745747
{
746-
path.push_back(round(j * (float)(m_condensed_data.num_mirror_groups) / num_crews));
748+
path.push_back(round((float)j * (float)(m_condensed_data.num_mirror_groups) / (float)num_crews));
747749
}
748750
return path;
749751
}
@@ -860,7 +862,7 @@ std::vector<int> WashCrewOptimizer::RetracePath(
860862
parent = parents[i*row_length + parent];
861863
}
862864

863-
for (int i = path.size()-1; i >= 0; i--)
865+
for (int i = (int)path.size()-1; i >= 0; i--)
864866
rev_path.push_back(path.at(i));
865867

866868
return rev_path;
@@ -877,7 +879,7 @@ void WashCrewOptimizer::CalculateSolutionObjective(std::unordered_map<std::strin
877879
for (size_t t = 0; t < m_settings.periods.size()-1; t++)
878880
{
879881
crews = m_results.num_crews_by_period[t];
880-
cost += rev_losses[int_pair_to_string(crews, t+1)];
882+
cost += rev_losses[int_pair_to_string(crews, (int)t+1)];
881883
ft_crews = std::min(crews, ft_crews);
882884
vehicles = std::max(crews, vehicles);
883885
}
@@ -1006,7 +1008,7 @@ void WashCrewOptimizer::OptimizeWashCrews(int scale, bool output)
10061008
//use the equal-assignment path if specified; otherwise, use DP output.
10071009

10081010
m_results.assignments_by_crews[i] = {0};
1009-
for (int c = 0; c < path.size()-1; c++)
1011+
for (int c = 0; c < (int)path.size()-1; c++)
10101012
m_results.assignments_by_crews[i].push_back(
10111013
GetNumberOfMirrors(path[c], path[c + 1])
10121014
);

liboptical/wash_opt_structure.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ wash_crew_settings::wash_crew_settings()
6060
wash_rate = 3677.885;
6161
heliostat_size = 115; //crescent dunes site
6262
crew_hours_per_week = 0.;
63-
total_cost_per_crew = 0.; //NPV
6463
system_efficiency = 0.;
6564
operating_margin = 1.;
6665
profit_per_kwh = 0.; //assuming 100% efficiency
6766
num_years = 0.; //years of operation to calculate NPV of annual costs
6867
price_per_kwh = 0.; //assumed average (no multiplier)
69-
annual_multiplier = 0.;
68+
annual_rev_multiplier = 0.;
7069
vehicle_life = 10;
7170
vehicle_cost = 100000.;
7271
seasonal_cost_multiple = 1.1;
@@ -85,12 +84,11 @@ void wash_crew_settings::print()
8584
<< "wash_rate" << ": " << wash_rate << "\n"
8685
<< "heliostat_size" << ": " << heliostat_size << "\n"
8786
<< "crew_hours_per_week" << ": " << crew_hours_per_week << "\n"
88-
<< "total_cost_per_crew" << ": " << total_cost_per_crew << "\n"
8987
<< "system_efficiency" << ": " << system_efficiency << "\n"
9088
<< "operating_margin" << ": " << operating_margin << "\n"
9189
<< "num_years" << ": " << num_years << "\n"
9290
<< "price_per_kwh" << ": " << price_per_kwh << "\n"
93-
<< "annual_multiplier" << ": " << annual_multiplier << "\n"
91+
<< "annual_rev_multiplier" << ": " << annual_rev_multiplier << "\n"
9492
<< "vehicle_life" << ": " << vehicle_life << "\n"
9593
<< "vehicle_cost" << ": " << vehicle_cost << "\n"
9694
<< "seasonal_cost_multiple" << ": " << seasonal_cost_multiple << "\n"

liboptical/wash_opt_structure.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,13 @@ struct wash_crew_settings
6666
double wash_rate; //in m^2 per hour
6767
double heliostat_size; //m^2
6868
double crew_hours_per_week;
69-
double crew_hours_per_day;
70-
double total_cost_per_crew; //NPV of labor and capital costs
7169
double system_efficiency; //assumed efficiency including receiver, TES losses, power cycle
7270
double profit_per_kwh; //per kwh dni sent to receiver, assuming 100% mirror efficiency
7371
double operating_margin; //used in calculating profit losses
7472
double num_years; //years of operation to calculate NPV of annual costs
7573
double price_per_kwh; //assumed average for grid output
76-
double annual_multiplier;
74+
double annual_rev_multiplier;
7775
double seasonal_cost_multiple;
78-
double soiling_rate;
7976
double vehicle_cost;
8077

8178
bool use_uniform_assignment;

liboptimize/optimize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ double continuous_objective_eval(unsigned n, const double *x, double *, void *da
6262
&P->m_financial_outputs.total_installed_cost,
6363
&P->m_design_outputs.area_sf,
6464
&P->m_optical_outputs.avg_soil,
65-
&P->m_optical_outputs.n_wash_crews,
65+
&P->m_optical_outputs.n_wash_vehicles,
66+
//&P->m_optical_outputs.wash_crew_schedule,
6667
&P->m_solarfield_outputs.n_om_staff,
6768
&P->m_optical_outputs.avg_degr,
6869
&P->m_simulation_outputs.annual_generation,

0 commit comments

Comments
 (0)