Skip to content

Commit

Permalink
Added outputs for spilled and unsupplied volumes into the interface a…
Browse files Browse the repository at this point in the history
…nd removed them from text outputs
  • Loading branch information
sylvmara committed Jun 24, 2024
1 parent 60eff8e commit e7ea4b3
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ class ClusterList
unsigned int index) const;

/*!
** @brief Get the reserve and spilled/unsupplied status and names for a given index of reserveParticipation
** @param area The area where to look for the reserveParticipation
** @param index Global index of the reserveParicipation
** @return the status and reserve names
*/
std::pair<Data::ThermalUnsuppliedSpilled, Data::ReserveName> reserveParticipationUnsuppliedSpilledAt(
const Area* area,
unsigned int index) const;

/*!
** \brief Resize all matrices dedicated to the sampled timeseries numbers
**
** \param n A number of years
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ enum ThermalDispatchableGroup
groupMax
};

enum ThermalUnsuppliedSpilled
{
//! Spilled
ThermalUnsuppliedSpilledSpilled = 0,
//! Unsupplied
ThermalUnsuppliedSpilledUnsupplied,

//! The highest value
unsuppliedSpilledMax
};

/*!
** \brief A single thermal cluster
*/
Expand Down
28 changes: 28 additions & 0 deletions src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,34 @@ std::pair<Data::ThermalDispatchableGroup, Data::ReserveName>
"reserve participations");
}

template<class ClusterT>
std::pair<Data::ThermalUnsuppliedSpilled, Data::ReserveName>
ClusterList<ClusterT>::reserveParticipationUnsuppliedSpilledAt(const Area* area, unsigned int index) const
{
int column = 0;
for (auto [reserveName, _] : area->allCapacityReservations.areaCapacityReservationsUp)
{
for (int indexUnsuppliedSpilled = 0; indexUnsuppliedSpilled < Data::unsuppliedSpilledMax; indexUnsuppliedSpilled++)
{
if (column == index)
return { static_cast<Data::ThermalUnsuppliedSpilled>(indexUnsuppliedSpilled), reserveName };
column++;
}
}
for (auto [reserveName, _] : area->allCapacityReservations.areaCapacityReservationsDown)
{
for (int indexUnsuppliedSpilled = 0; indexUnsuppliedSpilled < Data::unsuppliedSpilledMax; indexUnsuppliedSpilled++)
{
if (column == index)
return { static_cast<Data::ThermalUnsuppliedSpilled>(indexUnsuppliedSpilled), reserveName };
column++;
}
}
throw std::out_of_range("This reserve status index has not been found in all the "
"reserve participations");
}


template<class ClusterT>
ClusterT* ClusterList<ClusterT>::findInAll(std::string_view id) const
{
Expand Down
3 changes: 3 additions & 0 deletions src/solver/variable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ set(SRC_VARIABLE_ECONOMY
include/antares/solver/variable/economy/reserveParticipationCost.h
include/antares/solver/variable/economy/reserveParticipationByDispatchablePlant.h
include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h
include/antares/solver/variable/economy/reserveParticipationUnsuppliedSpilled.h
include/antares/solver/variable/economy/vCardReserveParticipationUnsuppliedSpilled.h
include/antares/solver/variable/economy/reserveParticipationByGroup.h
include/antares/solver/variable/economy/vCardreserveParticipationByGroup.h

# Links
include/antares/solver/variable/economy/links/flowLinear.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
** Copyright 2007-2023 RTE
** Authors: Antares_Simulator Team
**
** This file is part of Antares_Simulator.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** There are special exceptions to the terms and conditions of the
** license as they are applied to this software. View the full text of
** the exceptions in file COPYING.txt in the directory of this software
** distribution
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>.
**
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
*/
#ifndef __SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__
#define __SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__

#include "../storage/results.h"

namespace Antares
{
namespace Solver
{
namespace Variable
{
namespace Economy
{
struct VCardReserveParticipationUnsuppliedSpilled
{
//! Caption
static std::string Caption()
{
return "RESERVE UNSUPPLIED OR SPILLED ENERGY";
}
//! Unit
static std::string Unit()
{
return "MWh";
}

//! The short description of the variable
static std::string Description()
{
return "Reserve unsupplied or spilled Power";
}

//! The expected results
typedef Results<R::AllYears::Average< // The average values throughout all years
>>
ResultsType;

//! The VCard to look for for calculating spatial aggregates
typedef VCardReserveParticipationUnsuppliedSpilled VCardForSpatialAggregate;

enum
{
//! Data Level
categoryDataLevel = Category::area,
//! File level (provided by the type of the results)
categoryFileLevel = ResultsType::categoryFile & (Category::id | Category::va),
//! Precision (views)
precision = Category::all,
//! Indentation (GUI)
nodeDepthForGUI = +0,
//! Decimal precision
decimal = 0,
//! Number of columns used by the variable
columnCount = Category::dynamicColumns,
//! The Spatial aggregation
spatialAggregate = Category::spatialAggregateSum,
spatialAggregateMode = Category::spatialAggregateEachYear,
spatialAggregatePostProcessing = 0,
//! Intermediate values
hasIntermediateValues = 1,
//! Can this variable be non applicable (0 : no, 1 : yes)
isPossiblyNonApplicable = 0,
};

typedef IntermediateValues IntermediateValuesDeepType;
typedef IntermediateValues* IntermediateValuesBaseType;
typedef IntermediateValuesBaseType* IntermediateValuesType;

// typedef IntermediateValues IntermediateValuesType;

}; // class VCard

static std::string thermalUnsuppliedSpilledToString(Data::ThermalUnsuppliedSpilled idx)
{
switch (idx)
{
case 0:
return "UNSP.";
case 1:
return "SPIL.";
default:
return "<unknown>";
}
}

} // namespace Economy
} // namespace Variable
} // namespace Solver
} // namespace Antares

#endif //__SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include "dtgMarginAfterCsr.h"
#include "spilledEnergy.h"
#include "reserveParticipationCost.h"
#include "reserveParticipationByGroup.h"
#include "reserveParticipationUnsuppliedSpilled.h"

#include "lold.h"
#include "lolp.h"
Expand All @@ -75,7 +77,7 @@
#include "nbOfDispatchedUnitsByPlant.h"
#include "profitByPlant.h"
#include "reserveParticipationByDispatchablePlant.h"
#include "reserveParticipationByGroup.h"


// By RES plant
#include "productionByRenewablePlant.h"
Expand Down Expand Up @@ -174,9 +176,10 @@ typedef // Prices
<ReserveParticipationCost // Participation cost to the reserves
<ReserveParticipationByDispatchablePlant // Participation per cluster
<ReserveParticipationByGroup // Participation per thermal group
// Links
<Variable::Economy::Links // All links
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<ReserveParticipationUnsuppliedSpilled
// Links
<Variable::Economy::Links // All links
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
VariablesPerArea;

/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ class OverallCost : public Variable::IVariable<OverallCost<NextT>, NextT, VCardO
* (state.hourlyResults->TurbinageHoraire[state.hourInTheWeek]
- state.area->hydro.pumpingEfficiency
* state.hourlyResults->PompageHoraire[state.hourInTheWeek]));
Yuni::String buffer;
buffer << "Hour : " << state.hourInTheYear << "\n";
for (const auto& thermalReserves : state.problemeHebdo->allReserves.thermalAreaReserves)
{
for (const auto& reserveUp : thermalReserves.areaCapacityReservationsUp)
Expand All @@ -272,9 +270,6 @@ class OverallCost : public Variable::IVariable<OverallCost<NextT>, NextT, VCardO
+ state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalExcessReserve[reserveUp.globalReserveIndex]
* reserveUp.spillageCost;
buffer << " Reserve : " << reserveUp.reserveName << " Unsupplied : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalUnsatisfied[reserveUp.globalReserveIndex] << " mw, Spilled : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalExcessReserve[reserveUp.globalReserveIndex] << " mw. \n";
}
for (const auto& reserveDown : thermalReserves.areaCapacityReservationsDown)
{
Expand All @@ -285,35 +280,11 @@ class OverallCost : public Variable::IVariable<OverallCost<NextT>, NextT, VCardO
+ state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalExcessReserve[reserveDown.globalReserveIndex]
* reserveDown.spillageCost;
buffer << " Reserve : " << reserveDown.reserveName << " Unsupplied : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalUnsatisfied[reserveDown.globalReserveIndex] << " mw, Spilled : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek]
.ValeursHorairesInternalExcessReserve[reserveDown.globalReserveIndex] << " mw. \n";
}
}
state.spilledUnsupplied << buffer;

pValuesForTheCurrentYear[numSpace][state.hourInTheYear] += costForSpilledOrUnsuppliedEnergy;

if (state.hourInTheYear == state.study.runtime->rangeLimits.hour[Data::rangeEnd])
{
Yuni::String path;
path << state.study.folderOutput << SEP << "reserves" << SEP << state.area->name << ".txt";
Yuni::IO::File::Stream file;
Yuni::String pathFolder = state.study.folderOutput;
pathFolder << SEP << "reserves";
if (Yuni::IO::Directory::Exists(pathFolder) || Yuni::IO::Directory::Create(pathFolder))
{
if (file.openRW(path))
{
file << state.spilledUnsupplied;
file.close();
}
}
else
{
logs.error() << "Reserves : impossible to write " << path;
}
}

// Incrementing annual system cost (to be printed in output into a separate file)
state.annualSystemCost += costForSpilledOrUnsuppliedEnergy;

Expand Down
Loading

0 comments on commit e7ea4b3

Please sign in to comment.