Database Module¶
Module dealing with database IO
-
class
powergama.database.
Database
(filename)¶ Class for storing results from PowerGAMA in sqlite databse
Methods
appendResults
(timestep, objective_function, …)Store results from a given timestep to the database createTables
(data)Create database for PowerGAMA results getAverageInterareaBranchFlow
(timeMaxMin)Get average negative flow, positive flow and total flow of branches between different areas getBranchesSumFlow
(branches_pos, …)Return time series for aggregated flow along specified branches getGridBranches
()Get branch indices as a list getGridGeneratorFromArea
(area)Get indices of generators in given area as a list getGridInterareaBranches
()Get indices of branches between different areas as a list getGridNodeIndices
()Get node indices as a list getResultAreaPrices
(node_weight, timeMaxMin)Get area price timeseries getResultBranchFlow
(branchindx, timeMaxMin)Get branch flow at specified branch getResultBranchFlowAll
(timeMaxMin[, acdc])Get branch flow at all branches (list of tuples) getResultBranchFlowsMean
(timeMaxMin[, ac])Get average branch flow on branches in both direction getResultBranchLossesSum
(timeMaxMin[, acdc])Sum of losses for each time-step time step getResultBranchSens
(branchindx, timeMaxMin)Get branch capacity sensitivity at specified branch getResultBranchSensAll
(timeMaxMin)Get branch capacity sensitivity at all branches getResultBranchSensMean
(timeMaxMin[, acdc])Get average sensitivity of all branches acdc = ‘ac’ or ‘dc’ getResultBranches
(timeMaxMin[, br_indx, acdc])Branch results for each time-step getResultFlexloadPower
(consumerindx, timeMaxMin)Get flexible load for consumer with flexible load getResultFlexloadStorageFilling
(…)Get storage filling level for flexible loads getResultFlexloadStorageValue
(consumerindx, …)Get storage value for flexible loads getResultGeneratorPower
(generatorindx, …)Get power output time series for specified generator getResultGeneratorPowerInArea
(area, timeMaxMin)Get accumulated generation per type in given area getResultGeneratorPowerSum
(timeMaxMin)Sum of generator power output per generator getResultGeneratorSpilled
(generatorindx, …)Get spilled power time series for specified generator getResultGeneratorSpilledSums
(timeMaxMin)Get sum of spilled power for all generator getResultLoadheddingInArea
(area, timeMaxMin)Aggregated loadshedding timeseries for specified area getResultLoadheddingSum
(timeMaxMin)Sum of loadshedding timeseries per node getResultNodalPrice
(nodeindx, timeMaxMin)Get nodal price at specified node getResultNodalPricesAll
(timeMaxMin)Get nodal price at all nodes (list of tuples) getResultNodalPricesMean
(timeMaxMin)Get average nodal price at all nodes getResultPumpPower
(genindx, timeMaxMin)Get pumping for generators with pumping getResultPumpPowerMultiple
(genindx, timeMaxMin)Get pumping for generators with pumping getResultPumpingSum
(timeMaxMin[, variable])Sum of pumping per generator getResultStorageFilling
(genindx, timeMaxMin)Get storage filling level for storage generators getResultStorageFillingAll
(timestep)Get storage filling level for all storage generators getResultStorageFillingMultiple
(genindx, …)Get storage filling level for multiple storage generators getResultStorageValue
(storageindx, timeMaxMin)Get storage value for storage generators getResultStorageValueMultiple
(storageindx, …)Get average storage value (marginal price) for multiple storage generators getTimerange
()Get the timesteps -
SQLITE_MAX_VARIABLE_NUMBER
= 990¶
-
appendResults
(timestep, objective_function, generator_power, generator_pumped, branch_flow, dcbranch_flow, node_angle, sensitivity_branch_capacity, sensitivity_dcbranch_capacity, sensitivity_node_power, storage, inflow_spilled, loadshed_power, marginalprice, flexload_power, flexload_storage, flexload_storagevalue, idx_storagegen, idx_branchsens, idx_pumpgen, idx_flexload, branch_ac_losses, branch_dc_losses)¶ Store results from a given timestep to the database
Parameters: - timestep (int)
timestep number
- objective_function (float)
value of objective function
- generator_power (list of floats)
power output of generators
- generator_pumped (list of floats)
pumped power for generators
- branch_power (list of floats)
power flow on branches
- node_angle (list of floats)
phase angle (relative to node 0) at nodes
- sensitivity_branch_capacity (list of floats)
sensitivity to branch capacity
- sensitivity_dcbranch_capacity (list of floats)
sensitivty to DC branch capacity
- sensitivity_node_power (list of floats)
sensitivity to node power (nodal price)
- storage
storage filling level of generators
- inflow_spilled (list of floats)
spilled power inflow of generators
- loadshed_power (list of floats)
unmet power demand at nodes
- marginalprice
price of generators with storage
- flexload_power (list of floats)
flexible load power consumption
- flexload_storage
storage filling level of flexible load
- flexload_storagevalue
storage value in flexible load energy storage
- idx_storagegen
index in generator list of generators with storage
- idx_branchsens
index in branch list of branches with limited capacity
- idx_pumpgen
index in generator list of generators with pumping
- idx_flexload
index in consumer list of flexible loads
- branch_ac_losses : list
ac branch losses
- branch_dc_losses : list
dc branch losses
-
createTables
(data)¶ Create database for PowerGAMA results
-
getAverageInterareaBranchFlow
(timeMaxMin)¶ Get average negative flow, positive flow and total flow of branches between different areas
Returns: - List of tuples for inter-area branches with following values:
- (indices, fromArea, toArea, average negative flow, average positive
- flow, average flow)
-
getBranchesSumFlow
(branches_pos, branches_neg, timeMaxMin, acdc)¶ Return time series for aggregated flow along specified branches
branches_pos = indices of branches with positive flow direction branches_neg = indices of branches with negative flow direction timeMaxMin = [start, end] acdc = ‘ac’ or ‘dc’
Note: This function can be used to get net import, but not separate import/export values (requires summing positive and negative values separately)
-
getGridBranches
()¶ Get branch indices as a list
-
getGridGeneratorFromArea
(area)¶ Get indices of generators in given area as a list
Returns: - (indice)
-
getGridInterareaBranches
()¶ Get indices of branches between different areas as a list
Returns: - (indice, fromArea, toArea)
-
getGridNodeIndices
()¶ Get node indices as a list
-
getResultAreaPrices
(node_weight, timeMaxMin)¶ Get area price timeseries
node_weight = list of weights for each node
-
getResultBranchFlow
(branchindx, timeMaxMin, ac=True)¶ Get branch flow at specified branch
-
getResultBranchFlowAll
(timeMaxMin, acdc='ac')¶ Get branch flow at all branches (list of tuples)
Returns: - List of tuples with values:
- (timestep, branch index, flow)
-
getResultBranchFlowsMean
(timeMaxMin, ac=True)¶ Get average branch flow on branches in both direction
Parameters: - timeMaxMin (list of two elements) - time interval
- ac (bool) - ac (true) or dc (false) branches
Returns: - List with values for each branch:
- [average flow 1->2, average flow 2->1, average absolute flow]
-
getResultBranchLossesSum
(timeMaxMin, acdc='ac')¶ Sum of losses for each time-step time step
-
getResultBranchSens
(branchindx, timeMaxMin, acdc='ac')¶ Get branch capacity sensitivity at specified branch
-
getResultBranchSensAll
(timeMaxMin)¶ Get branch capacity sensitivity at all branches
-
getResultBranchSensMean
(timeMaxMin, acdc='ac')¶ Get average sensitivity of all branches acdc = ‘ac’ or ‘dc’
-
getResultBranches
(timeMaxMin, br_indx=None, acdc='ac')¶ Branch results for each time-step
Parameters: - timeMaxMin : [start,end]
tuple with time window start <= t < end
- br_indx : list (optional)
list of branches to consider, None=include all
-
getResultFlexloadPower
(consumerindx, timeMaxMin)¶ Get flexible load for consumer with flexible load
-
getResultFlexloadStorageFilling
(consumerindx, timeMaxMin)¶ Get storage filling level for flexible loads
-
getResultFlexloadStorageValue
(consumerindx, timeMaxMin)¶ Get storage value for flexible loads
-
getResultGeneratorPower
(generatorindx, timeMaxMin)¶ Get power output time series for specified generator
-
getResultGeneratorPowerInArea
(area, timeMaxMin)¶ Get accumulated generation per type in given area
-
getResultGeneratorPowerSum
(timeMaxMin)¶ Sum of generator power output per generator
-
getResultGeneratorSpilled
(generatorindx, timeMaxMin)¶ Get spilled power time series for specified generator
-
getResultGeneratorSpilledSums
(timeMaxMin)¶ Get sum of spilled power for all generator
-
getResultLoadheddingInArea
(area, timeMaxMin)¶ Aggregated loadshedding timeseries for specified area
-
getResultLoadheddingSum
(timeMaxMin)¶ Sum of loadshedding timeseries per node
-
getResultNodalPrice
(nodeindx, timeMaxMin)¶ Get nodal price at specified node
-
getResultNodalPricesAll
(timeMaxMin)¶ Get nodal price at all nodes (list of tuples)
Returns: - List of tuples with values:
- (timestep, node index, nodal price)
-
getResultNodalPricesMean
(timeMaxMin)¶ Get average nodal price at all nodes
-
getResultPumpPower
(genindx, timeMaxMin)¶ Get pumping for generators with pumping
-
getResultPumpPowerMultiple
(genindx, timeMaxMin, negative=True)¶ Get pumping for generators with pumping
-
getResultPumpingSum
(timeMaxMin, variable='output')¶ Sum of pumping per generator
-
getResultStorageFilling
(genindx, timeMaxMin)¶ Get storage filling level for storage generators
-
getResultStorageFillingAll
(timestep)¶ Get storage filling level for all storage generators
-
getResultStorageFillingMultiple
(genindx, timeMaxMin, capacity=None)¶ Get storage filling level for multiple storage generators
-
getResultStorageValue
(storageindx, timeMaxMin)¶ Get storage value for storage generators
-
getResultStorageValueMultiple
(storageindx, timeMaxMin)¶ Get average storage value (marginal price) for multiple storage generators
-
getTimerange
()¶ Get the timesteps
-