Skip to content

Commit

Permalink
Merge branch 'feature/series-solar' into feature/series
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 9, 2023
2 parents 4cafa88 + 1c91c83 commit 70a5cf9
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 341 deletions.
3 changes: 0 additions & 3 deletions src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ set(SRC_STUDY
# Solar
parts/solar/container.h
parts/solar/container.cpp
parts/solar/series.h
parts/solar/series.hxx
parts/solar/series.cpp
parts/solar/prepro.cpp
parts/solar/prepro.h
parts/solar/prepro.hxx
Expand Down
7 changes: 2 additions & 5 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ void Area::createMissingData()

void Area::createMissingTimeSeries()
{
if (!solar.series)
solar.series = new DataSeriesSolar();
if (!hydro.series)
hydro.series = new DataSeriesHydro();
thermal.list.ensureDataTimeSeries();
Expand Down Expand Up @@ -265,13 +263,12 @@ void Area::resizeAllTimeseriesNumbers(uint n)
assert(n < 200000); // arbitrary number

// asserts
assert(solar.series and "solar.series must not be nullptr !");
assert(hydro.series and "series must not be nullptr !");

if (!n)
{
load.series.timeseriesNumbers.clear();
solar.series->timeseriesNumbers.clear();
solar.series.timeseriesNumbers.clear();
wind.series.timeseriesNumbers.clear();
hydro.series->timeseriesNumbers.clear();
for (auto& namedLink : links)
Expand All @@ -283,7 +280,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
else
{
load.series.timeseriesNumbers.resize(1, n);
solar.series->timeseriesNumbers.resize(1, n);
solar.series.timeseriesNumbers.resize(1, n);
wind.series.timeseriesNumbers.resize(1, n);
hydro.series->timeseriesNumbers.resize(1, n);
for (auto& namedLink : links)
Expand Down
5 changes: 0 additions & 5 deletions src/libs/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,6 @@ void AreaListClearAllLinks(AreaList* l);
*/
void AreaListEnsureDataLoadPrepro(AreaList* l);

/*!
** \brief Ensure data for load time-series are initialized
*/
void AreaListEnsureDataSolarTimeSeries(AreaList* l);

/*!
** \brief Ensure data for solar prepro are initialized
*/
Expand Down
25 changes: 5 additions & 20 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const
<< area.id;
ret = area.solar.prepro->saveToFolder(buffer) && ret;
}
if (area.solar.series) // Series
{
buffer.clear() << folder << SEP << "input" << SEP << "solar" << SEP << "series";
ret = DataSeriesSolarSaveToFolder(area.solar.series, area.id, buffer.c_str()) && ret;
}
buffer.clear() << folder << SEP << "input" << SEP << "solar" << SEP << "series";
ret = area.solar.series.timeSeriesSaveToFolder(area.id, buffer.c_str(), "solar_") && ret;
}

// Hydro
Expand Down Expand Up @@ -872,10 +869,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
<< area.id;
ret = area.solar.prepro->loadFromFolder(buffer) && ret;
}
if (area.solar.series && (!options.loadOnlyNeeded || !area.solar.prepro)) // Series
if (!options.loadOnlyNeeded || !area.solar.prepro) // Series
{
buffer.clear() << study.folderInput << SEP << "solar" << SEP << "series";
ret = DataSeriesSolarLoadFromFolder(study, area.solar.series, area.id, buffer.c_str())
ret = area.solar.series.timeSeriesLoadFromFolder(study, area.id, buffer.c_str(), "solar_")
&& ret;
}

Expand Down Expand Up @@ -1031,7 +1028,6 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,

void AreaList::ensureDataIsInitialized(Parameters& params, bool loadOnlyNeeded)
{
AreaListEnsureDataSolarTimeSeries(this);
AreaListEnsureDataHydroTimeSeries(this);
AreaListEnsureDataThermalTimeSeries(this);
AreaListEnsureDataRenewableTimeSeries(this);
Expand Down Expand Up @@ -1250,17 +1246,6 @@ void AreaListEnsureDataLoadPrepro(AreaList* l)
});
}

void AreaListEnsureDataSolarTimeSeries(AreaList* l)
{
/* Asserts */
assert(l);

l->each([&](Data::Area& area) {
if (!area.solar.series)
area.solar.series = new DataSeriesSolar();
});
}

void AreaListEnsureDataSolarPrepro(AreaList* l)
{
/* Asserts */
Expand Down Expand Up @@ -1590,7 +1575,7 @@ void AreaList::removeHydroTimeseries()

void AreaList::removeSolarTimeseries()
{
each([&](Data::Area& area) { area.solar.series->timeSeries.reset(1, HOURS_PER_YEAR); });
each([&](Data::Area& area) { area.solar.series.timeSeries.reset(1, HOURS_PER_YEAR); });
}

void AreaList::removeWindTimeseries()
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/store-timeseries-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void storeTimeseriesNumbersForLoad(Solver::IResultWriter& writer, const Area& ar

void storeTimeseriesNumbersForSolar(Solver::IResultWriter& writer, const Area& area)
{
genericStoreTimeseriesNumbers(writer, area.solar.series->timeseriesNumbers, area.id, "solar");
genericStoreTimeseriesNumbers(writer, area.solar.series.timeseriesNumbers, area.id, "solar");
}

void storeTimeseriesNumbersForHydro(Solver::IResultWriter& writer, const Area& area)
Expand Down
8 changes: 7 additions & 1 deletion src/libs/antares/study/parts/common/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ using namespace Yuni;
namespace Antares::Data
{

const double TimeSeries::emptyColumn[] = {0};

int TimeSeries::timeSeriesLoadFromFolder(Study& s,
const AreaName& areaID,
const std::string& folder,
Expand Down Expand Up @@ -76,11 +78,15 @@ void TimeSeries::reset()

double TimeSeries::getCoefficient(uint32_t year, uint32_t hourInYear) const
{
if (timeSeries.width == 0)
return 0;
return timeSeries[getSeriesIndex(year)][hourInYear];
}

double* TimeSeries::getColumn(uint32_t year) const
const double* TimeSeries::getColumn(uint32_t year) const
{
if (timeSeries.width == 0)
return emptyColumn;
return timeSeries[getSeriesIndex(year)];
}

Expand Down
4 changes: 3 additions & 1 deletion src/libs/antares/study/parts/common/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TimeSeries
const std::string& filename) const;

double getCoefficient(uint32_t year, uint32_t hourInYear) const;
double* getColumn(uint32_t year) const;
const double* getColumn(uint32_t year) const;
uint32_t getSeriesIndex(uint32_t year) const;

void reset();
Expand All @@ -76,6 +76,8 @@ class TimeSeries

Matrix<double, int32_t> timeSeries;
TSNumbers timeseriesNumbers;

static const double emptyColumn[HOURS_PER_YEAR];
};

/*!
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/study/parts/parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "load/container.h"

// Solar
#include "solar/series.h"
#include "solar/prepro.h"
#include "solar/container.h"

Expand Down
17 changes: 6 additions & 11 deletions src/libs/antares/study/parts/solar/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,39 @@ namespace Data
{
namespace Solar
{
Container::Container() : prepro(nullptr), series(nullptr)
{
}
Container::Container() : prepro(nullptr)
{}

Container::~Container()
{
delete prepro;
delete series;
}

bool Container::forceReload(bool reload) const
{
bool ret = true;
if (series)
ret = series->forceReload(reload) && ret;
ret = series.forceReload(reload) && ret;
if (prepro)
ret = prepro->forceReload(reload) && ret;
return ret;
}

void Container::markAsModified() const
{
if (series)
series->markAsModified();
series.markAsModified();
if (prepro)
prepro->markAsModified();
}

uint64_t Container::memoryUsage() const
{
return sizeof(Container) + ((!series) ? 0 : DataSeriesSolarMemoryUsage(series))
return sizeof(Container) + series.memoryUsage()
+ ((!prepro) ? 0 : prepro->memoryUsage());
}

void Container::resetToDefault()
{
if (series)
series->timeSeries.reset(1, HOURS_PER_YEAR);
series.timeSeries.reset();
if (prepro)
prepro->resetToDefault();
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/solar/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef __ANTARES_LIBS_STUDY_PARTS_SOLAR_CONTAINER_H__
#define __ANTARES_LIBS_STUDY_PARTS_SOLAR_CONTAINER_H__

#include "series.h"
#include <antares/study/parts/common/series.h>

namespace Antares
{
Expand Down Expand Up @@ -73,7 +73,7 @@ class Container
//! Data for the pre-processor
Data::Solar::Prepro* prepro;
/*! Data for time-series */
DataSeriesSolar* series;
TimeSeries series;

}; // class Container

Expand Down
115 changes: 0 additions & 115 deletions src/libs/antares/study/parts/solar/series.cpp

This file was deleted.

Loading

0 comments on commit 70a5cf9

Please sign in to comment.