Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Maximum Generation and Pumping for Hydro (RTEi's -> CR23) #1470

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
2b03609
Maxgen matrix implemented
nikolaredstork Jul 13, 2023
e25aea9
Maxpump matrix implemented
nikolaredstork Jul 13, 2023
9bbe22e
Scenario Builder GUI
nikolaredstork Jul 22, 2023
ab3085f
DataSeriesHydro-new matrix for max gen and pump TS's
nikolaredstork Jul 22, 2023
f2bd3ac
MC years linked with new hydro MC Scenario Builder Matrix
nikolaredstork Jul 22, 2023
5a80015
Random number feature
nikolaredstork Jul 22, 2023
f602cc6
Replacing daily values for hourly in solver
nikolaredstork Jul 22, 2023
22d74c4
HydroHasMod and PumpHasMod
nikolaredstork Jul 22, 2023
34a314b
Hydro Modulabe
nikolaredstork Jul 22, 2023
0fb26de
GUI for TS management hydro power credits
nikolaredstork Jul 22, 2023
e2e963a
Inter and Intra modal feature backend
nikolaredstork Jul 23, 2023
a4d33db
Auto Transfer function and one comment modification
nikolaredstork Jul 23, 2023
eee6d08
Comment modification
nikolaredstork Jul 23, 2023
a4c1da8
Refactoring checkHourlyMinMaxGeneration function
nikolaredstork Jul 23, 2023
827cfb5
Separate function for checking max gen and pump TS number
nikolaredstork Jul 23, 2023
07ce46b
Excluding unnecessary function parameter
nikolaredstork Jul 23, 2023
4b08e13
Excluding unnecessary reference
nikolaredstork Jul 24, 2023
ede8efc
HydroHasMod and PumpHasMod modification
nikolaredstork Jul 24, 2023
598a474
Change function name
nikolaredstork Jul 24, 2023
4554d23
MD files updated
nikolaredstork Jul 24, 2023
94ca6b7
MD file modification
nikolaredstork Jul 25, 2023
2ab16dc
Merge branch 'develop-new' into feature/maxgen-maxpump-cr23
nikolaredstork Jul 31, 2023
13db210
Modification after merging with develop-new branch
nikolaredstork Jul 31, 2023
04b6104
Fixing build errors due to migration from raw ptrs to stl vectors
nikolaredstork Jul 31, 2023
1820fda
Support for old studies fix
nikolaredstork Aug 2, 2023
94698f1
Separate mingen from maxgen and maxpump
nikolaredstork Aug 3, 2023
75b6263
New Load function for Hydro Power Credits
nikolaredstork Aug 3, 2023
91435e9
fix - random ts number test crash
Milos-RTEi Aug 3, 2023
c672e3a
fix pumpMaxE bug
Milos-RTEi Aug 3, 2023
118db9a
Separate mingen from maxgen and maxpump
nikolaredstork Aug 3, 2023
7ee9ccf
fix - random ts number test crash
Milos-RTEi Aug 3, 2023
4b165d2
fix pumpMaxE bug
Milos-RTEi Aug 3, 2023
6cad434
Bugfix
nikolaredstork Aug 4, 2023
401e21a
Merge branch 'feature/max-hydro-gen-pump-per-h-cr23' into feature/max…
Milos-RTEi Aug 4, 2023
75cb113
Feature/maxgen maxpump cr23 - improvements (#1499)
Milos-RTEi Aug 4, 2023
bcdc18b
Adding pointer check
nikolaredstork Aug 4, 2023
8e35773
Adding pointer check
nikolaredstork Aug 4, 2023
4abc817
New file maxhours_areaID
nikolaredstork Aug 8, 2023
c104436
New class that support old studies
nikolaredstork Aug 9, 2023
0667a39
Two separate files for Gen and Pump hours
nikolaredstork Aug 11, 2023
7138ced
Delete old files
nikolaredstork Aug 14, 2023
cabdc79
Scenario Builder unit tests
nikolaredstork Aug 14, 2023
94784ea
Excluding unnecessary code
nikolaredstork Aug 14, 2023
c8f2050
Keep files for an area
nikolaredstork Aug 14, 2023
a33099d
Excluding unnecessary arrays
nikolaredstork Aug 15, 2023
21cd52e
Fix test
nikolaredstork Aug 16, 2023
7fa96b3
New file maxhours_areaID
nikolaredstork Aug 8, 2023
b5f0573
New class that support old studies
nikolaredstork Aug 9, 2023
aadaa26
Two separate files for Gen and Pump hours
nikolaredstork Aug 11, 2023
8ff8737
Delete old files
nikolaredstork Aug 14, 2023
0d9e8e5
Scenario Builder unit tests
nikolaredstork Aug 14, 2023
a4f00a2
Excluding unnecessary code
nikolaredstork Aug 14, 2023
c142ee9
Keep files for an area
nikolaredstork Aug 14, 2023
644c50b
Excluding unnecessary arrays
nikolaredstork Aug 15, 2023
172d8a9
Fix test
nikolaredstork Aug 16, 2023
68d4299
Merge branch 'develop-new' into feature/maxgen-maxpump-cr23
nikolaredstork Aug 16, 2023
1ec8f3e
Post merge fixs
nikolaredstork Aug 16, 2023
552b48a
Merge branch 'feature/maxgen-maxpump-cr23' into feature/max-hydro-gen…
Milos-RTEi Aug 16, 2023
be21fda
Merge branch 'develop-new' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 16, 2023
578c6e5
Post merge build fix
nikolaredstork Aug 17, 2023
fb0c474
Fix sonar bugs
nikolaredstork Aug 17, 2023
a9e6519
Exclude duplication code
nikolaredstork Aug 17, 2023
b2899d5
Some minor code smells
nikolaredstork Aug 17, 2023
596d9f4
More code smells
nikolaredstork Aug 18, 2023
54bbc79
Resolving Code smells
nikolaredstork Aug 18, 2023
2672405
Unit test datatransfer
nikolaredstork Aug 21, 2023
f78e096
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 21, 2023
20a4738
Post merge build fix
nikolaredstork Aug 21, 2023
b1874ec
Additional datatransfer unit tests
nikolaredstork Aug 22, 2023
32b56e5
LoadPowerCredits func unit tests
nikolaredstork Aug 22, 2023
c0643bb
Comment correction
nikolaredstork Aug 22, 2023
838c04c
Additional comments
nikolaredstork Aug 22, 2023
376f24d
Refactoring unit tests
nikolaredstork Aug 23, 2023
1eb238c
Refactoring hydro series unit tests
nikolaredstork Aug 23, 2023
fe47970
Help files for unit tests
nikolaredstork Aug 23, 2023
8fa59e9
Exclude unnecessary code
nikolaredstork Aug 23, 2023
25c4b23
MD files
nikolaredstork Aug 23, 2023
426b3c9
Remove function for unit tests
nikolaredstork Aug 24, 2023
9cd3f88
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 24, 2023
edd5c50
Passing by reference
nikolaredstork Aug 25, 2023
5354e87
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 25, 2023
867aa5b
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 25, 2023
81850af
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Aug 31, 2023
030af42
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Sep 4, 2023
7c5ddc5
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Sep 8, 2023
f1c3673
Copy from UI
nikolaredstork Sep 13, 2023
d21f858
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Sep 13, 2023
6c01298
Post merge build errors
nikolaredstork Sep 15, 2023
fd1e1eb
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Sep 18, 2023
baa6994
Merge branch 'develop' into feature/max-hydro-gen-pump-per-h-cr23
nikolaredstork Sep 21, 2023
00b8592
Post merge build errors resolved
nikolaredstork Sep 21, 2023
cc82545
Multiple Maximum Generation and Pumping for Hydro (Refactoring) (#1648)
nikolaredstork Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guide/03-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ this command allows to state, for each kind of time-series, whether it should be
the available set (be it ready-made or Antares-generated) _**OR**_ should take a user-defined value
(in the former case, the default "rand" value should be kept; in the latter, the value should be the reference number of the time-series to use). Multiple simulation profiles can be defined and archived. The default active profile gives the "rand" status for all time-series in all areas (full probabilistic simulation).

Regarding Hydro time-series, the scenario builder gives, in addition to the assignment of a specific number to use for the inflows time-series, the ability to define the initial reservoir level to use for each MC year.
Regarding Hydro time-series, the scenario builder gives, in addition to the assignment of a specific number to use for the inflows time-series, the ability to define the initial reservoir level to use for each MC year, also hydro power credits scenario builder is available to support time-series for Maximum Generation and Maximum Pumping because the number of TS's for ROR, Hydro Storage and Minimum Generation can be different than the number of TS's for Maximum Generation and Maximum Pumping.
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved

- **MC Scenario playlist** For each Monte-Carlo year of the simulation defined in the "Simulation" active window,
this command allows to state whether a MC year prepared for the simulation should be actually simulated or not.
Expand Down
19 changes: 10 additions & 9 deletions docs/reference-guide/04-active_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ These two parts are detailed hereafter.

### RIGHT PART: Time-series management

For the different kinds of time-series that Antares manages in a non-deterministic way (load, thermal generation, hydro power, wind power, solar power or renewable depending on the option chosen):
For the different kinds of time-series that Antares manages in a non-deterministic way (load, thermal generation, hydro power, hydro power credits, wind power, solar power or renewable depending on the option chosen):

1. **Choice of the kind of time-series to use**
Either « ready-made » or «stochastic » (i.e. Antares-generated), defined by setting the value to either "on" or "off". Note that for Thermal time-series, the cluster-wise parameter may overrule this global parameter (see Thermal window description below).
Either « ready-made » or «stochastic » (i.e. Antares-generated), defined by setting the value to either "on" or "off". Exception is hydro power credits that can only be « ready-made ». Note that for Thermal time-series, the cluster-wise parameter may overrule this global parameter (see Thermal window description below).

2. **For stochastic TS only**:
- **Number** Number of TS to generate
Expand Down Expand Up @@ -295,11 +295,11 @@ which explains the comparatively long length of this chapter.

In the main Window, the user may pick any area appearing in the list and is then given access to different tabs:

- The "time-series" tab displays the "ready-made" time-series already available for simulation purposes. There are two categories of time-series (displayed in two different subtabs): the Run of River (ROR) time-series on the one hand and the Storage power (SP) time-series on the other hand.
- The "time-series" tab displays the "ready-made" time-series already available for simulation purposes. There are five categories of time-series (displayed in five different subtabs): the Run of River (ROR) time-series, the Storage power (SP) time-series, the Minimum Generation power, the Maximum Generation power and the Maximum Pumping Power.

ROR time-series are defined at the hourly scale; each of the 8760 values represents the ROR power expected at a given hour, expressed in round number and in MW. The SP time-series are defined at the daily scale; each of the 365 values represents an overall SP energy expected in the day, expressed in round number and in MWh. These natural inflows are considered to be storable into a reservoir for later use.
ROR time-series are defined at the hourly scale; each of the 8760 values represents the ROR power expected at a given hour, expressed in round number and in MW. The SP time-series are defined at the daily scale; each of the 365 values represents an overall SP energy expected in the day, expressed in round number and in MWh. These natural inflows are considered to be storable into a reservoir for later use. The Minimum Generation time-series are defined at the hourly scale; each of the 8760 values represents the Minimum Generation power expected at a given hour expressed in round number and in MW. The Maximum Generation time-series are defined at the hourly scale; each of the 8760 values represents the Maximum Generation power expected at a given hour expressed in round number and in MW. The Maximum Pumping time-series are defined at the hourly scale; each of the 8760 values represents the Maximum Pumping power expected at a given hour expressed in round number and in MW.

Both types of data may come from any origin outside Antares, or may have been formerly generated by the Antares time-series stochastic generator and stored as input data on the user's request. Different ways to update data are:
ROR time-series and SP time-series may come from any origin outside Antares, or may have been formerly generated by the Antares time-series stochastic generator and stored as input data on the user's request. Minimum Generation, Maximum Generation and Maximum Pumping may come from any origin outside Antares, but they can not be generated by the Antares time-series stochastic generator. Different ways to update data are:

- direct typing
- copy/paste a selected field to/from the clipboard
Expand All @@ -313,7 +313,8 @@ In the main Window, the user may pick any area appearing in the list and is then

- _Note that:_

- _For a given area, the number of ROR time-series and SP times-series **must** be identical_
- _For a given area, the number of ROR time-series, SP times-series and Minimum Generation **must** be identical_
- _For a given area, the number of Maximum Generation and Maximum Pumping **must** be identical_
- _If the "intra-modal correlated draws" option was not selected in the_ **simulation** _window,
MC adequacy or economy simulations can take place even if the number of hydro time-series is not the same
in all areas (e.g. 2 , 5 , 1 , 45 ,...)_
Expand Down Expand Up @@ -376,10 +377,10 @@ the weekly optimal hydro-thermal unit-commitment and dispatch process.
Standard credits (Bottom part)

The bottom part displays two daily time-series (365 values) defined for energy generation/storage
(hydro turbines or hydro pumps). In each case, the first array defines the maximum power (generated or absorbed),
and the second defines the maximum daily energy (either generated or stored).
(hydro turbines or hydro pumps). Both arrays represents the maximum daily energy (either generated or stored).

For the sake of clarity, maximum daily energies are expressed as a number of hours at maximum power.
For the sake of clarity, maximum daily energies are expressed as a number of hours at maximum power and these values
are used along with the Maximum Generation and Maximum Pumping TS's to calculate daily mean energy.

Credit modulation (Upper part)

Expand Down
8 changes: 8 additions & 0 deletions docs/reference-guide/13-file-format.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Study format changes
This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts.
## v8.8.0
For each area, new files are added **input/hydro/series/<area>/maxgen.txt** and **input/hydro/series/<area>/maxpump.txt**. These files have one or more columns, and 8760 rows. The number of columns in these two files must be the same, if there is more than one column in each file, but if there is just one column for example in maxgen.txt file, maxpump.txt file can have more than one column and vice versa. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not. In that case maxgen.txt and maxpump.txt files will have just one column and 8760 rows.

Also for each area, new files are added **input/hydro/common/capacity/maxhoursGen_<area>** and **input/hydro/common/capacity/maxhoursPump_<area>**. These files have just one column and 365 rows. For old studies, file **input/hydro/common/capacity/maxpower_<area>** will be deleted after upgrading the study and corresponding data from that file will be copied to already mentioned new files, even if study is upgraded or not.
### Input
Under `Configure/MC Scenario Builder` new section added `Hydro-Power-Credits`
In the existing file **settings/scenariobuilder.dat**, under **<ruleset>** section following properties added:
* **hgp,<area>,<year> = <hgp-value>**
## v8.7.0
### Input
#### Scenarized RHS for binding constraints
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ set(SRC_STUDY_SCENARIO_BUILDER
study/scenario-builder/ThermalTSNumberData.h
study/scenario-builder/HydroTSNumberData.h
study/scenario-builder/HydroTSNumberData.cpp
study/scenario-builder/HydroPowerCreditsTSNumberData.h
study/scenario-builder/HydroPowerCreditsTSNumberData.cpp
study/scenario-builder/SolarTSNumberData.cpp
study/scenario-builder/solarTSNumberData.h
study/scenario-builder/WindTSNumberData.h
Expand Down Expand Up @@ -266,6 +268,8 @@ set(SRC_STUDY_PART_HYDRO
study/parts/hydro/allocation.h
study/parts/hydro/allocation.hxx
study/parts/hydro/allocation.cpp
study/parts/hydro/datatransfer.h
study/parts/hydro/datatransfer.cpp
)
source_group("study\\part\\hydro" FILES ${SRC_STUDY_PART_HYDRO})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ void Create::createActionsForAStandardAreaCopy(Context& ctx, bool copyPosition)
*tsNode += prepro;
*tsNode += new Action::AntaresStudy::Area::AllocationHydro(pOriginalAreaName);

//Hydro Power Credits
*tsNode += new DataTimeseries(Data::timeSeriesHydroPowerCredits, pOriginalAreaName);

// Thermal
auto* area = ctx.extStudy->areas.findFromName(pOriginalAreaName);
if (area)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ DataTimeseries::DataTimeseries(Data::TimeSeries ts, const AnyString& areaname) :
case Data::timeSeriesThermal:
pInfos.caption << "Thermal : Timeseries";
break;
case Data::timeSeriesHydroPowerCredits:
pInfos.caption << "Power-Credits : Timeseries";
break;
default:
break;
}
Expand Down Expand Up @@ -103,6 +106,9 @@ void DataTimeseries::registerViewsWL(Context& ctx)
case Data::timeSeriesThermal:
ctx.view["6:Thermal"]["1:TS"] = this;
break;
case Data::timeSeriesHydroPowerCredits:
ctx.view["7:Power-Credits"]["1:TS"] = this;
break;
default:
break;
}
Expand Down Expand Up @@ -164,9 +170,19 @@ bool DataTimeseries::performWL(Context& ctx)
source->hydro.series->ror.unloadFromMemory();
source->hydro.series->storage.unloadFromMemory();
source->hydro.series->mingen.unloadFromMemory();

break;
}
case Data::timeSeriesHydroPowerCredits:
{
ctx.area->hydro.series->maxgen = source->hydro.series->maxgen;
ctx.area->hydro.series->maxpump = source->hydro.series->maxpump;

ctx.area->hydro.series->countpowercredits = source->hydro.series->countpowercredits;

source->hydro.series->maxgen.unloadFromMemory();
source->hydro.series->maxpump.unloadFromMemory();
}
case Data::timeSeriesThermal:
{
if (ctx.cluster && ctx.originalPlant && ctx.cluster != ctx.originalPlant)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
solar.series->timeseriesNumbers.clear();
wind.series->timeseriesNumbers.clear();
hydro.series->timeseriesNumbers.clear();
hydro.series->timeseriesNumbersPowerCredits.clear();
for (auto& namedLink : links)
{
AreaLink* link = namedLink.second;
Expand All @@ -292,6 +293,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
solar.series->timeseriesNumbers.resize(1, n);
wind.series->timeseriesNumbers.resize(1, n);
hydro.series->timeseriesNumbers.resize(1, n);
hydro.series->timeseriesNumbersPowerCredits.resize(1, n);
for (auto& namedLink : links)
{
AreaLink* link = namedLink.second;
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ class Area final : private Yuni::NonCopyable<Area>
void createMissingTimeSeries();
void createMissingPrepros();


}; // class Area

bool saveAreaOptimisationIniFile(const Area& area, const Yuni::Clob& buffer);
Expand Down
29 changes: 29 additions & 0 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,32 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
ret = area.hydro.series->loadFromFolder(study, area.id, buffer) && ret;
}

if (area.hydro.series && study.header.version < 870)
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
{
std::shared_ptr<DataTransfer> datatransfer = std::make_shared<DataTransfer>();
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
buffer.clear() << study.folderInput << SEP << "hydro";

datatransfer->LoadFromFolder(study, buffer, area);
datatransfer->SupportForOldStudies(study, buffer, area);
}

if (area.hydro.series)
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
{
buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "series";
ret = area.hydro.series->LoadHydroPowerCredits(study, area.id, buffer) && ret;
}

buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "common" << SEP
<< "capacity" << SEP << "maxpower_" << area.id << '.'
<< study.inputExtension;

bool exists = IO::File::Exists(buffer);

if (study.header.version >= 870 && exists)
{
IO::File::Delete(buffer);
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
}

++options.progressTicks;
options.pushProgressLogs();
}
Expand Down Expand Up @@ -1611,7 +1637,10 @@ void AreaList::removeHydroTimeseries()
area.hydro.series->ror.reset(1, HOURS_PER_YEAR);
area.hydro.series->storage.reset(1, DAYS_PER_YEAR);
area.hydro.series->mingen.reset(1, HOURS_PER_YEAR);
area.hydro.series->maxgen.reset(1, HOURS_PER_YEAR);
area.hydro.series->maxpump.reset(1, HOURS_PER_YEAR);
area.hydro.series->count = 1;
area.hydro.series->countpowercredits = 1;
});
}

Expand Down
66 changes: 34 additions & 32 deletions src/libs/antares/study/area/scratchpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts
originalMustrunSum[h] = std::numeric_limits<double>::quiet_NaN();
}

for (uint d = 0; d != DAYS_PER_YEAR; ++d)
{
optimalMaxPower[d] = std::numeric_limits<double>::quiet_NaN();
pumpingMaxPower[d] = std::numeric_limits<double>::quiet_NaN();
}

// Fatal hors hydro
// Fatal hors hydro
{
double sum;
uint w;
Expand Down Expand Up @@ -90,22 +84,13 @@ AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts
// Hydro generation permission
// ------------------------------
// Useful whether we use a heuristic target or not
bool hydroGenerationPermission = false;
bool hydroGenerationPermission = false;

// ... Getting hydro max power
auto const& maxPower = area.hydro.maxPower;

// ... Hydro max generating power and energy
auto const& maxGenP = maxPower[Data::PartHydro::genMaxP];
auto const& maxGenE = maxPower[Data::PartHydro::genMaxE];

double value = 0.;
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
value += maxGenP[d] * maxGenE[d];
auto const& maxPower = area.hydro.series->maxgen;
auto const& maxGenHours = area.hydro.maxHoursGen[0];

// If generating energy is nil over the whole year, hydroGenerationPermission is false, true
// otherwise.
hydroGenerationPermission = (value > 0.);
hydroGenerationPermission = CheckForPositiveEnergy(maxPower, maxGenHours);

// ---------------------
// Hydro has inflows
Expand Down Expand Up @@ -141,23 +126,40 @@ AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts
// ... Hydro max power

// ... Hydro max pumping power and energy
auto const& maxPumpingP = maxPower[Data::PartHydro::pumpMaxP];
auto const& maxPumpingE = maxPower[Data::PartHydro::pumpMaxE];

// ... Pumping max power
for (uint d = 0; d != DAYS_PER_YEAR; ++d)
pumpingMaxPower[d] = maxPumpingP[d];

double valuePumping = 0.;
// ... Computing 'pumpHasMod' parameter
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
valuePumping += maxPumpingP[d] * maxPumpingE[d];
auto const& maxPumpingP = area.hydro.series->maxpump;
auto const& maxPumpHours = area.hydro.maxHoursPump[0];
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved

// If pumping energy is nil over the whole year, pumpHasMod is false, true otherwise.
pumpHasMod = (valuePumping > 0.);
pumpHasMod = CheckForPositiveEnergy(maxPumpingP, maxPumpHours);
}

AreaScratchpad::~AreaScratchpad() = default;

bool AreaScratchpad::CheckForPositiveEnergy(const Matrix<double, Yuni::sint32>& matrix,
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
const Matrix<double>::ColumnType& hours)
{
double value = 0.;
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved

for (uint width = 0; width < matrix.width; ++width)
{
for (uint d = 0; d < DAYS_PER_YEAR; ++d)
{
value += CalculateDailyMeanPower(d, matrix[width]) * hours[d];
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved

if (value > 0.)
return true;
}

value = 0.;
}

return false;
}

double CalculateDailyMeanPower(uint dYear, const Matrix<double>::ColumnType& maxPower)
{
return std::accumulate(maxPower + dYear * 24, maxPower + dYear * 24 + 24, 0) / 24.;
}

} // namespace Data
} // namespace Antares
15 changes: 8 additions & 7 deletions src/libs/antares/study/area/scratchpad.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <antares/array/matrix.h>
#include <vector>
#include <set>
#include <numeric>

namespace Antares
{
Expand Down Expand Up @@ -90,21 +91,21 @@ class AreaScratchpad final
// This variable is initialized every MC-year
double originalMustrunSum[HOURS_PER_YEAR];

//! Optimal max power (OPP) - Hydro management
double optimalMaxPower[DAYS_PER_YEAR];

//!
double pumpingMaxPower[DAYS_PER_YEAR];

/*!
/*!
** \brief Dispatchable Generation Margin
**
** Those values, written by the output, must be calculated before
** running the hydro remix.
*/
double dispatchableGenerationMargin[168];

private:
bool CheckForPositiveEnergy(const Matrix<double, Yuni::sint32>& matrix,
const Matrix<double>::ColumnType& hours);
}; // class AreaScratchpad

double CalculateDailyMeanPower(uint dYear, const Matrix<double>::ColumnType& maxPower);

} // namespace Data
} // namespace Antares

Expand Down
6 changes: 6 additions & 0 deletions src/libs/antares/study/area/store-timeseries-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ void storeTimeseriesNumbersForHydro(Solver::IResultWriter::Ptr writer, const Are
genericStoreTimeseriesNumbers(writer, area.hydro.series->timeseriesNumbers, area.id, "hydro");
}


void storeTimeseriesNumbersForHydroPowerCredits(Solver::IResultWriter::Ptr writer, const Area& area)
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
{
genericStoreTimeseriesNumbers(writer, area.hydro.series->timeseriesNumbersPowerCredits, area.id, "power-credits");
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved
}

void storeTimeseriesNumbersForWind(Solver::IResultWriter::Ptr writer, const Area& area)
{
genericStoreTimeseriesNumbers(writer, area.wind.series->timeseriesNumbers, area.id, "wind");
Expand Down
1 change: 1 addition & 0 deletions src/libs/antares/study/area/store-timeseries-numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Antares::Data
void storeTimeseriesNumbersForThermal(Solver::IResultWriter::Ptr writer, const Area& area);
void storeTimeseriesNumbersForRenewable(Solver::IResultWriter::Ptr writer, const Area& area);
void storeTimeseriesNumbersForTransmissionCapacities(Solver::IResultWriter::Ptr writer, const Area& area);
void storeTimeseriesNumbersForHydroPowerCredits(Solver::IResultWriter::Ptr writer, const Area& area);

} //Antares::Data

Expand Down
Loading