Time Series Module¶
This module provides functions for time series analysis of power flows and optimal power flow.
functions are found in pyflow_acdc.Time_series
Sequential AC/DC Time Series Power Flow¶
Cross-sectional time series¶
- TS_ACDC_PF(grid, start=1, end=99999, print_step=False)¶
Performs sequential AC/DC power flow for time series data.
Parameter
Type
Description
Default
gridGrid
Grid to analyze
Required
startint
Start time step
1
endint
End time step
99999
print_stepbool
Print progress
False
Returns
Results are stored in
grid.time_series_resultsdictionary with the following keys:PF_results: Node voltages and power flowsline_loading: Line loading percentagesac_line_loading: AC line loading percentagesdc_line_loading: DC line loading percentagesconverter_loading: Converter loading percentagesgrid_loading: Overall grid loading
Example
pyf.TS_ACDC_PF(grid, start=1, end=24)
Simple Time-Series Power Flow¶
- Time_series_PF(grid)¶
Runs time-series power flow using the configured grid time-series inputs.
Grid Data Update Helper¶
- update_grid_data(grid, ts, idx, price_zone_restrictions=False, use_clusters=False, n_clusters=None)¶
Internal helper that applies one time-step (or one clustered state) to grid data before solving PF/OPF routines.
Optimal Power Flow Time Series¶
Cross-sectional time series¶
- TS_ACDC_OPF(grid, start=1, end=99999, ObjRule=None, price_zone_restrictions=False, expand=False, print_step=False)¶
Performs time series optimal power flow analysis.
Parameter
Type
Description
Default
gridGrid
Grid to analyze
Required
startint
Start time step
1
endint
End time step
99999
ObjRuledict
Objective rule, check Objective Functions for more details
None
price_zone_restrictionsbool
Price zone restrictions, adds price zone restrictions to the model [1]
False
expandbool
Expand price zone import limits
False
print_stepbool
Print step in the terminal
False
Returns
Results are stored in
grid.time_series_resultsdictionary with the following keys:converter_p_dc- Converter power in DC sideconverter_q_ac- Converter power in AC sideconverter_p_ac- Converter power in AC sideconverter_loading- Converter loading percentagesreal_load_opf- Real load per nodereal_power_opf- Real power per generatorreactive_power_opf- Reactive power per generatorcurtailment- Curtailment valuesline_loading- Line loading percentagesgrid_loading- Loading by unsynchronized gridsprices_by_zone- Prices by price zoneprices_by_zone_total- Total prices by price zoneac_line_loading- AC line loading percentagesdc_line_loading- DC line loading percentagesreal_load_by_zone- Real load per price zonereal_power_by_zone- Real power per price zone
It also returns a dictionary with the timing information.
Example
import pyflow_acdc as pyf import pandas as pd [grid,results] = pyf.NS_MTDC() start = 5750 end = 6000 obj = {'Energy_cost': 1} market_prices_url = "https://raw.githubusercontent.com/CITCEA-UPC/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_marketPrices_data_sd2024.csv" TS_MK = pd.read_csv(market_prices_url) pyf.add_TimeSeries(grid,TS_MK) wind_load_url = "https://raw.githubusercontent.com/CITCEA-UPC/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_WL_data2024.csv" TS_wl = pd.read_csv(wind_load_url) pyf.add_TimeSeries(grid,TS_wl) times=pyf.TS_ACDC_OPF(grid,start,end,ObjRule=obj) res_dict = grid.time_series_results
Parallel cross-sectional time series¶
- TS_ACDC_OPF_parallel(grid, ObjRule=None, PV_set=False, OnlyGen=True, Price_Zones=False)¶
Performs parallel time series optimal power flow analysis. Creates parallel sub-models to speed up the calculation.
Returns Results are saved in
grid.time_series_resultsand the average elapsed time is returned.Example
average_elapsed_time=pyf.TS_ACDC_OPF_parallel(grid)
Data handling¶
Statistical Analysis¶
- Time_series_statistics(grid, curtail=0.99, over_loading=0.9)¶
Calculates statistical metrics for time series results.
Parameter
Type
Description
Default
gridGrid
Grid with results
Required
curtailfloat
Curtailment percentile
0.99
over_loadingfloat
Overloading threshold
0.9
Calculates for each time series:
Mean
Median
Maximum/Minimum
Mode
IQR
Percentiles
Results Export¶
- results_TS_OPF(grid, excel_file_path, grid_names=None, stats=None, times=None)¶
Exports time series results to Excel file.
Parameter
Type
Description
Default
gridGrid
Grid with results
Required
excel_file_pathstr
Output file path
Required
grid_namesdict
Grid name mappings
None
statsDataFrame
Statistical results
None
timesdict
Computation times
None
Exports sheets for:
Time- Timing informationAll line loadings (AC/DC)- All line loadings (AC/DC)AC line loadings- AC line loading percentagesDC line loadings- DC line loading percentagesGrid loadings- Grid loading percentagesConverter DC power- Converter power in DC sideConverter AC power- Converter power in AC sideConverter AC reactive power- Converter reactive power in AC sideReal load per node- Real load per nodeReal power per generator- Real power per generatorReactive power per generator- Reactive power per generatorCurtailment- CurtailmentConverter loading- Converter loading percentagesReal load by zone- Real load by zoneReal power by zone- Real power by zoneReactive power by zone- Reactive power by zonePrices by zone- Prices by zoneStatistics- Statistics
Example
pyf.results_TS_OPF(grid, "results", stats=stats_df)
References