Skip to content

Commit

Permalink
Fix : Wind & Solar time-series set as generated, but renewable policy…
Browse files Browse the repository at this point in the history
… is "Clusters" (#650)

* Fix : Wind & Solar time-series set as generated, but renewable policy is "Clusters"

In case we're in the situation described by the commit title, a crash occurs at execution.
Program tries to copy a wind TS though it was not loaded nor generated.
So we avoid that copy (that we don't need anyway) when the renewable policy is not aggregated.

* Apply clang-format

Co-authored-by: Florian OMNES <[email protected]>
  • Loading branch information
guilpier-code and flomnes authored Apr 20, 2022
1 parent e4369fa commit bf37a0a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 12 additions & 5 deletions src/solver/variable/commons/solar.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class TimeSeriesValuesSolar
pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel];
for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);

isRenewableGenerationAggregrated = study.parameters.renewableGeneration.isAggregated();

// Next
NextType::initializeFromStudy(study);
}
Expand Down Expand Up @@ -192,11 +195,14 @@ class TimeSeriesValuesSolar

void yearBegin(unsigned int year, unsigned int numSpace)
{
// The current time-series
(void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
pArea->solar.series->series
.entry[NumeroChroniquesTireesParPays[numSpace][pArea->index]->Solar],
sizeof(double) * pArea->solar.series->series.height);
if (isRenewableGenerationAggregrated)
{
// The current solar time-series
(void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
pArea->solar.series->series
.entry[NumeroChroniquesTireesParPays[numSpace][pArea->index]->Solar],
sizeof(double) * pArea->solar.series->series.height);
}

// Next variable
NextType::yearBegin(year, numSpace);
Expand Down Expand Up @@ -278,6 +284,7 @@ class TimeSeriesValuesSolar
//! Intermediate values for each year
typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
unsigned int pNbYearsParallel;
bool isRenewableGenerationAggregrated = true;

}; // class TimeSeriesValuesSolar

Expand Down
18 changes: 11 additions & 7 deletions src/solver/variable/commons/wind.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class TimeSeriesValuesWind
for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);

isRenewableGenerationAggregrated = study.parameters.renewableGeneration.isAggregated();

// Next
NextType::initializeFromStudy(study);
}
Expand Down Expand Up @@ -192,13 +194,14 @@ class TimeSeriesValuesWind

void yearBegin(unsigned int year, unsigned int numSpace)
{
// The current time-series
const Matrix<>::ColumnType& load
= pArea->wind.series->series
.entry[NumeroChroniquesTireesParPays[numSpace][pArea->index]->Eolien];
(void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
load,
sizeof(double) * pArea->wind.series->series.height);
if (isRenewableGenerationAggregrated)
{
// The current wind time-series
(void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
pArea->wind.series->series
.entry[NumeroChroniquesTireesParPays[numSpace][pArea->index]->Eolien],
sizeof(double) * pArea->wind.series->series.height);
}

// Next variable
NextType::yearBegin(year, numSpace);
Expand Down Expand Up @@ -280,6 +283,7 @@ class TimeSeriesValuesWind
//! Intermediate values for each year
typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
unsigned int pNbYearsParallel;
bool isRenewableGenerationAggregrated = true;

}; // class TimeSeriesValuesWind

Expand Down

0 comments on commit bf37a0a

Please sign in to comment.