Skip to content

Commit

Permalink
Introduce & use DataSeriesCommon::getAvailablePowerYearly (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored Sep 29, 2023
1 parent f23b312 commit 1fa52a8
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/libs/antares/study/parts/common/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ double DataSeriesCommon::getAvailablePower(unsigned int hour, unsigned int year)
{
return timeSeries[getSeriesIndex(year)][hour];
}

const DataSeriesCommon::SingleYear& DataSeriesCommon::getAvailablePowerYearly(unsigned int year) const
{
return timeSeries[getSeriesIndex(year)];
}

uint DataSeriesCommon::getSeriesIndex(unsigned int year) const
{
if (timeSeries.width == 1)
Expand Down
6 changes: 5 additions & 1 deletion src/libs/antares/study/parts/common/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,24 @@ namespace Antares::Data
class DataSeriesCommon
{
public:
using AllYears = Matrix<double>;
using SingleYear = AllYears::ColumnType;

bool forceReload(bool reload = false) const;

void markAsModified() const;

uint64_t memoryUsage() const;

double getAvailablePower(unsigned int hour, unsigned int year) const;
const SingleYear& getAvailablePowerYearly(unsigned int year) const;

/*!
** \brief Series (MW)
**
** Merely a matrix of TimeSeriesCount * 8760 values
*/
Matrix<double> timeSeries;
AllYears timeSeries;

/*!
** \brief Monte-Carlo
Expand Down
4 changes: 2 additions & 2 deletions src/solver/optimisation/post_process_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime
for (auto i = area.thermal.list.begin(); i != end; ++i)
{
auto& cluster = *(i->second);
const auto& availableProduction = cluster.series->getAvailablePowerYearly(year);
for (uint h = 0; h != nbHoursInWeek; ++h)
{
double production = hourlyResults.ProductionThermique[h]
.ProductionThermiqueDuPalier[cluster.index];
double availability = cluster.series->getAvailablePower(h + hourInYear, year);
dtgmrg[h] += availability - production;
dtgmrg[h] += availableProduction[h + hourInYear] - production;
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/solver/simulation/common-eco-adq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uin
for (auto i = area.thermal.mustrunList.begin(); i != end; ++i)
{
auto& cluster = *(i->second);

const auto& availableProduction = cluster.series->getAvailablePowerYearly(year);
if (inAdequacy && cluster.mustrunOrigin)
{
for (uint h = 0; h != cluster.series->timeSeries.height; ++h)
{
mrs[h] += cluster.series->getAvailablePower(h, year);
adq[h] += cluster.series->getAvailablePower(h, year);
mrs[h] += availableProduction[h];
adq[h] += availableProduction[h];
}
}
else
{
for (uint h = 0; h != cluster.series->timeSeries.height; ++h)
mrs[h] += cluster.series->getAvailablePower(h, year);
mrs[h] += availableProduction[h];
}
}
}
Expand All @@ -165,8 +165,9 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uin
if (!cluster.mustrunOrigin)
continue;

const auto& availableProduction = cluster.series->getAvailablePowerYearly(year);
for (uint h = 0; h != cluster.series->timeSeries.height; ++h)
adq[h] += cluster.series->getAvailablePower(h, year);
adq[h] += availableProduction[h];
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/solver/ts-generator/thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust

auto& modulation = cluster.modulation[Data::thermalModulationCapacity];

Matrix<>::ColumnType* dstSeries = nullptr;
Antares::Data::DataSeriesCommon::SingleYear dstSeries = nullptr;

const uint tsCount = nbThermalTimeseries + 2;
for (uint tsIndex = 0; tsIndex != tsCount; ++tsIndex)
{
uint hour = 0;

if (tsIndex > 1)
dstSeries = &cluster.series->timeSeries[tsIndex - 2];
dstSeries = cluster.series->timeSeries[tsIndex - 2];

for (uint dayInTheYear = 0; dayInTheYear < daysPerYear; ++dayInTheYear)
{
Expand Down Expand Up @@ -596,7 +596,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust
double AVPDayInTheYear = AVP[dayInTheYear];
for (uint h = 0; h != 24; ++h)
{
(*dstSeries)[hour] = Math::Round(AVPDayInTheYear * modulation[hour]);
dstSeries[hour] = Math::Round(AVPDayInTheYear * modulation[hour]);
++hour;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/solver/variable/economy/avail-dispatchable-generation.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ class AvailableDispatchGen
{
for (auto& [name, cluster] : list)
{
const auto& availableProduction = cluster->series->getAvailablePowerYearly(year);
for (unsigned int hour = 0; hour != cluster->series->timeSeries.height; ++hour)
pValuesForTheCurrentYear[numSpace].hour[hour] += cluster->series->getAvailablePower(hour, year);
pValuesForTheCurrentYear[numSpace].hour[hour] += availableProduction[hour];
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/solver/variable/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,15 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex)
maxDurationON = endHourForCurrentYear;

// min, and max unit ON calculation
const auto& availableProduction = currentCluster->series->getAvailablePowerYearly(this->year);
for (uint h = startHourForCurrentYear; h < endHourForCurrentYear; ++h)
{
maxUnitNeeded = 0u;
ON_min[h] = 0u;
ON_max[h] = 0u;

// Getting available production from cluster data
double thermalClusterAvailableProduction = currentCluster->series->getAvailablePower(h, this->year);
double thermalClusterAvailableProduction = availableProduction[h];
double thermalClusterProduction = 0.;
if (currentCluster->mustrun)
{
Expand Down

0 comments on commit 1fa52a8

Please sign in to comment.