This folder contains files for: (a) Simulating optimal battery charging and discharging (based on daily cycles) given (i) wholesale market prices by trading period (averages by transmission pricing zone) (ii) assumptions about battery configurations, including size (MW) and range of operation (maximum and minimum storage) (iii) peak demand (e.g. RCPD) charges (iv) uncertainty about when peak demand periods occur. (b) Fitting functions to describe a continuous relationship between earnings (revenue net of costs) from battery investment and the scale of battery investment and size of peak demand charges (such as RCPD charges). This includes an ex-post adjustment to energy prices in response to changes in demand. Output from the function fitting includes a desrciption of net changes in grid demand by time of use (with time of use defined prior to battery operation). Simulation is undertaken using the python file "Simulation_3_years_multiple_capacities_uncertain.py'. Input data is 'PriceAndVolume_2010_to_2019_RCPD_N_100.csv' Outputs are 'daily_cycles_variable_MW_uncertain.csv' (baseline, with RCPD charge) and 'daily_cycles_variable_MW_no_RCPD.csv' (proposal, no RCPD charge). Functions are fitted in the R file "Battery invest function workings uncertain and price response.R". Input data 'daily_cycles_variable_MW_uncertain.csv' (baseline, with RCPD charge) and 'daily_cycles_variable_MW_no_RCPD.csv' (proposal, no RCPD charge). Outputs are 'earnings_functions_uncertain_supply_response.csv' and 'changes_to_demand_by_TOU_defined_without_battery_batteries_supply_response.csv'.