From ea3905f275cb3412eb068e30f286ff54390d6bba Mon Sep 17 00:00:00 2001 From: Luke Marshall Date: Tue, 21 Jan 2020 17:08:22 +1100 Subject: [PATCH] Bug fixes as per Rob's feedback --- .../data/luomi/defaults/load_data.csv | 78 +++++++++---------- .../data/luomi/defaults/solar_data.csv | 66 ++++++++-------- .../modelling/luomi_model/energy_sim.py | 6 +- .../modelling/luomi_model/financial_sim.py | 12 ++- .../modelling/luomi_model/tariffs.py | 12 ++- 5 files changed, 95 insertions(+), 79 deletions(-) diff --git a/Flask/application/modelling/data/luomi/defaults/load_data.csv b/Flask/application/modelling/data/luomi/defaults/load_data.csv index 76c6ad8..57161d8 100644 --- a/Flask/application/modelling/data/luomi/defaults/load_data.csv +++ b/Flask/application/modelling/data/luomi/defaults/load_data.csv @@ -1,39 +1,39 @@ -timestamp,Participant 1 -26/02/2017 3:30,0.051 -26/02/2017 4:00,0.016 -26/02/2017 4:30,0.035 -26/02/2017 5:00,0.043 -26/02/2017 5:30,0.011000000000000001 -26/02/2017 6:00,0.043 -26/02/2017 6:30,0.035 -26/02/2017 7:00,0.013000000000000001 -26/02/2017 7:30,0.047 -26/02/2017 8:00,0.028999999999999998 -26/02/2017 8:30,0.019 -26/02/2017 9:00,0.048 -26/02/2017 9:30,0.022000000000000002 -26/02/2017 10:00,0.028999999999999998 -26/02/2017 10:30,0.05 -26/02/2017 11:00,0.064 -26/02/2017 11:30,0.07200000000000001 -26/02/2017 12:00,0.066 -26/02/2017 12:30,0.013000000000000001 -26/02/2017 13:00,0.062 -26/02/2017 13:30,0.02 -26/02/2017 14:00,0.044000000000000004 -26/02/2017 14:30,0.038 -26/02/2017 15:00,0.026000000000000002 -26/02/2017 15:30,0.055 -26/02/2017 16:00,0.013999999999999999 -26/02/2017 16:30,0.055 -26/02/2017 17:00,0.027000000000000003 -26/02/2017 17:30,0.035 -26/02/2017 18:00,0.047 -26/02/2017 18:30,0.013000000000000001 -26/02/2017 19:00,0.057999999999999996 -26/02/2017 19:30,0.024 -26/02/2017 20:00,0.034 -26/02/2017 20:30,0.047 -26/02/2017 21:00,0.013000000000000001 -26/02/2017 21:30,0.05 -26/02/2017 22:00,0.03 +timestamp,Participant 1,Participant 2,Participant 3,Participant 4,Participant 5,Participant 6,Participant 7,Participant 8,Participant 9,Participant 10,Participant 11 +26/02/2017 3:30,0.265,0.051,5.58,0.096,0.556,0.23,0.147,0.145,0.0,0.08,0.121 +26/02/2017 4:00,0.158,0.016,7.392,0.095,0.6809999999999999,0.205,0.132,0.255,0.0,0.035,0.10099999999999999 +26/02/2017 4:30,0.168,0.035,6.96,0.061,0.713,0.31,0.153,0.159,0.0,0.094,0.08900000000000001 +26/02/2017 5:00,0.168,0.043,6.292000000000001,0.091,0.684,0.218,0.13699999999999998,0.537,0.0,0.253,0.077 +26/02/2017 5:30,0.17,0.011000000000000001,7.18,0.065,0.6829999999999999,0.273,0.159,0.304,0.0,0.127,0.081 +26/02/2017 6:00,0.433,0.043,5.78,0.081,0.7040000000000001,0.2,0.125,1.351,0.001,0.035,0.08199999999999999 +26/02/2017 6:30,0.155,0.035,6.62,0.084,0.708,0.265,0.037000000000000005,0.005,0.0,0.038,0.07400000000000001 +26/02/2017 7:00,0.158,0.013000000000000001,6.0520000000000005,0.086,0.7070000000000001,0.205,0.0,0.0,0.0,0.040999999999999995,0.11900000000000001 +26/02/2017 7:30,0.165,0.047,5.66,0.10099999999999999,0.71,0.5579999999999999,0.0,0.0,0.0,0.035,0.098 +26/02/2017 8:00,0.165,0.028999999999999998,7.652,0.08,0.711,0.22,0.0,0.0,0.0,0.187,0.102 +26/02/2017 8:30,0.17,0.019,7.06,0.105,0.71,0.228,0.0,0.0,0.0,0.043,0.073 +26/02/2017 9:00,0.165,0.048,7.92,0.08,0.708,0.21,0.0,0.0,0.001,0.036000000000000004,0.08800000000000001 +26/02/2017 9:30,0.16,0.022000000000000002,6.372000000000001,0.102,0.546,0.25,0.0,0.0,0.0,0.036000000000000004,0.079 +26/02/2017 10:00,0.158,0.028999999999999998,7.412000000000001,0.08,1.202,0.212,0.0,0.0,0.0,0.039,0.081 +26/02/2017 10:30,0.165,0.05,7.38,0.078,1.01,0.24,0.0,0.033,0.001,0.040999999999999995,0.109 +26/02/2017 11:00,0.17,0.064,9.32,0.08,0.9990000000000001,0.21,0.0,0.0,0.0,0.035,0.106 +26/02/2017 11:30,0.168,0.07200000000000001,9.3,0.065,0.995,0.245,0.0,0.0,0.001,0.038,0.11599999999999999 +26/02/2017 12:00,0.17300000000000001,0.066,10.12,0.531,0.9740000000000001,0.23800000000000002,0.0,0.0,0.0,0.043,0.075 +26/02/2017 12:30,0.163,0.013000000000000001,9.14,0.9,0.9740000000000001,0.198,0.0,0.0,0.0,0.035,0.09 +26/02/2017 13:00,0.43,0.062,7.88,0.9390000000000001,0.9890000000000001,0.27,0.0,0.0,0.0,0.038,0.07 +26/02/2017 13:30,0.163,0.02,7.032,0.894,1.0070000000000001,0.22,0.0,0.0,0.001,0.043,0.092 +26/02/2017 14:00,0.17300000000000001,0.044000000000000004,7.02,0.903,1.05,0.223,0.0,0.0,0.0,0.036000000000000004,0.085 +26/02/2017 14:30,0.175,0.038,6.76,0.903,0.978,0.5,0.0,0.0,0.0,0.038,0.125 +26/02/2017 15:00,0.17300000000000001,0.026000000000000002,7.52,0.894,0.983,0.28,0.0,0.0,0.0,0.043,0.10300000000000001 +26/02/2017 15:30,0.165,0.055,6.772,0.9179999999999999,0.9840000000000001,0.198,0.0,0.0,0.0,0.036000000000000004,0.10800000000000001 +26/02/2017 16:00,0.163,0.013999999999999999,7.332000000000001,0.8759999999999999,0.987,0.253,0.0,0.0,0.0,0.038,0.077 +26/02/2017 16:30,0.163,0.055,7.24,0.258,1.004,0.253,0.0,0.035,0.0,0.043,0.083 +26/02/2017 17:00,0.168,0.027000000000000003,7.66,0.054000000000000006,0.968,0.28300000000000003,0.0,0.073,0.0,0.036000000000000004,0.08199999999999999 +26/02/2017 17:30,0.175,0.035,7.98,0.096,0.953,0.27,0.013999999999999999,0.20600000000000002,0.0,0.038,0.078 +26/02/2017 18:00,0.17,0.047,7.247999999999999,0.091,0.951,0.2,0.032,0.369,0.0,0.043,0.114 +26/02/2017 18:30,0.21,0.013000000000000001,7.38,0.086,0.9279999999999999,0.253,0.14800000000000002,0.897,0.0,0.036000000000000004,0.10800000000000001 +26/02/2017 19:00,0.268,0.057999999999999996,6.48,0.054000000000000006,0.7829999999999999,0.233,0.159,0.371,0.0,0.038,0.126 +26/02/2017 19:30,0.268,0.024,7.1,0.068,0.55,0.233,0.14300000000000002,0.24100000000000002,0.0,0.042,0.084 +26/02/2017 20:00,0.54,0.034,8.36,0.068,0.5529999999999999,0.205,0.158,0.239,0.0,0.036000000000000004,0.092 +26/02/2017 20:30,0.273,0.047,7.76,0.051,0.8959999999999999,0.278,0.13699999999999998,0.261,0.0,0.038,0.075 +26/02/2017 21:00,0.273,0.013000000000000001,6.172000000000001,0.076,0.535,0.18,0.159,0.22399999999999998,0.0,0.042,0.083 +26/02/2017 21:30,0.275,0.05,6.34,0.045,0.56,0.568,0.239,0.8190000000000001,0.0,0.036000000000000004,0.08199999999999999 +26/02/2017 22:00,0.275,0.03,6.492000000000001,0.07200000000000001,0.5670000000000001,0.212,0.18600000000000003,0.248,0.001,0.036000000000000004,0.10400000000000001 diff --git a/Flask/application/modelling/data/luomi/defaults/solar_data.csv b/Flask/application/modelling/data/luomi/defaults/solar_data.csv index 92305e7..729a492 100644 --- a/Flask/application/modelling/data/luomi/defaults/solar_data.csv +++ b/Flask/application/modelling/data/luomi/defaults/solar_data.csv @@ -1,33 +1,33 @@ -timestamp,Participant 1 -26/02/2017 3:30,0.0 -26/02/2017 4:00,0.0 -26/02/2017 4:30,0.0 -26/02/2017 5:00,0.0 -26/02/2017 5:30,0.0 -26/02/2017 6:00,0.003553005 -26/02/2017 6:30,0.023523041 -26/02/2017 7:00,0.063444426 -26/02/2017 7:30,0.10172237099999999 -26/02/2017 8:00,0.132877758 -26/02/2017 8:30,0.155646496 -26/02/2017 9:00,0.195606224 -26/02/2017 9:30,0.21376504 -26/02/2017 10:00,0.230492471 -26/02/2017 10:30,0.265317402 -26/02/2017 11:00,0.283608925 -26/02/2017 11:30,0.275362531 -26/02/2017 12:00,0.276618717 -26/02/2017 12:30,0.26093375399999996 -26/02/2017 13:00,0.246004392 -26/02/2017 13:30,0.24648402600000002 -26/02/2017 14:00,0.219712813 -26/02/2017 14:30,0.19128016899999997 -26/02/2017 15:00,0.15310075199999998 -26/02/2017 15:30,0.138380662 -26/02/2017 16:00,0.13468988099999998 -26/02/2017 16:30,0.111056339 -26/02/2017 17:00,0.077142938 -26/02/2017 17:30,0.04358589 -26/02/2017 18:00,0.01380429 -26/02/2017 18:30,0.001296576 -26/02/2017 19:00,0.0 +timestamp,Participant 1,Participant 2,Participant 3,Participant 4,Participant 5,Participant 6,Participant 7,Participant 8,Participant 9,Participant 10,Participant 11 +26/02/2017 3:30,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 +26/02/2017 4:00,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 +26/02/2017 4:30,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 +26/02/2017 5:00,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 +26/02/2017 5:30,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 +26/02/2017 6:00,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005,0.003553005 +26/02/2017 6:30,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041,0.023523041 +26/02/2017 7:00,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426,0.063444426 +26/02/2017 7:30,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999,0.10172237099999999 +26/02/2017 8:00,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758,0.132877758 +26/02/2017 8:30,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496,0.155646496 +26/02/2017 9:00,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224,0.195606224 +26/02/2017 9:30,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504,0.21376504 +26/02/2017 10:00,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471,0.230492471 +26/02/2017 10:30,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402,0.265317402 +26/02/2017 11:00,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925,0.283608925 +26/02/2017 11:30,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531,0.275362531 +26/02/2017 12:00,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717,0.276618717 +26/02/2017 12:30,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996,0.26093375399999996 +26/02/2017 13:00,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392,0.246004392 +26/02/2017 13:30,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002,0.24648402600000002 +26/02/2017 14:00,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813,0.219712813 +26/02/2017 14:30,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997,0.19128016899999997 +26/02/2017 15:00,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998,0.15310075199999998 +26/02/2017 15:30,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662,0.138380662 +26/02/2017 16:00,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998,0.13468988099999998 +26/02/2017 16:30,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339,0.111056339 +26/02/2017 17:00,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938,0.077142938 +26/02/2017 17:30,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589,0.04358589 +26/02/2017 18:00,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429,0.01380429 +26/02/2017 18:30,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576,0.001296576 +26/02/2017 19:00,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 diff --git a/Flask/application/modelling/luomi_model/energy_sim.py b/Flask/application/modelling/luomi_model/energy_sim.py index 70cb005..d601785 100644 --- a/Flask/application/modelling/luomi_model/energy_sim.py +++ b/Flask/application/modelling/luomi_model/energy_sim.py @@ -89,13 +89,15 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) # Allocate battery export when there is battery export and all solar has been used by this participant if battery_allocation > 0 and reject_solar <= 0 : + print("SUP I got some BATTERY OPERATION going right now.") participant_net_export = participants_list_sorted.loc[p,'net_export'] participant_central_batt_import = min(abs(battery_allocation), abs(participant_net_export) - abs(local_solar_import)) results.set_participant_central_batt_import(time, p, participant_central_batt_import) available_batt -= participant_central_batt_import battery_allocation = float(available_batt) / float(num_remaining_participants) if num_remaining_participants > 0 else 0 - - + # else: + # print('Battery not operating', battery_allocation, reject_solar) + # Save any solar left over after the allocation process to df_network_energy_flows results.set_unallocated_local_solar(time, available_solar) diff --git a/Flask/application/modelling/luomi_model/financial_sim.py b/Flask/application/modelling/luomi_model/financial_sim.py index ec61227..d76fd4a 100644 --- a/Flask/application/modelling/luomi_model/financial_sim.py +++ b/Flask/application/modelling/luomi_model/financial_sim.py @@ -110,10 +110,11 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) else: variable_tariff = offpeak_charge # Apply the tariff - results.set_participant_variable_charge(time, p.get_id(),variable_tariff * external_grid_import ) + results.set_participant_variable_charge(time, p.get_id(),variable_tariff * external_grid_import) # Total bill - + participant_duos_payments = results.get_participant_duos_payments(time, p.get_id()) + participant_tuos_payments = results.get_participant_tuos_payments(time, p.get_id()) participant_variable_charge = results.get_participant_variable_charge(time, p.get_id()) local_solar_import_charge = results.get_local_solar_import_charge(time, p.get_id()) central_batt_import_charge = results.get_central_batt_import_charge(time, p.get_id()) @@ -123,7 +124,7 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) fixed_charge = results.get_fixed_charge(time, p.get_id()) # Add charges and subtract revenue for total bill - total_bill = participant_variable_charge + local_solar_import_charge + central_batt_import_charge + fixed_charge - local_solar_sales_revenue - central_batt_solar_sales_revenue - export_to_grid_solar_sales_revenue + total_bill = participant_variable_charge + participant_duos_payments + participant_tuos_payments + local_solar_import_charge + central_batt_import_charge + fixed_charge - local_solar_sales_revenue - central_batt_solar_sales_revenue - export_to_grid_solar_sales_revenue results.set_total_participant_bill(time, p.get_id(), total_bill) @@ -384,6 +385,7 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) previous_month = time_periods[0].month for time in time_periods: + # Update callback status if status_callback: percent_finished += single_step_percent @@ -440,6 +442,8 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) else: variable_tariff = offpeak_charge # Apply the tariff + # print("LUKE NUOS", variable_tariff, external_grid_import) + # print("LUKE NUOS offpeak, shoulder and peak charges", offpeak_charge, shoulder_charge, peak_charge) results.set_participant_nuos_payments(time, p.get_id(), variable_tariff * external_grid_import) # Demand tariff includes TOU component which is handled above. In addition, the demand component is calculated for each participant @@ -504,6 +508,8 @@ def simulate(time_periods, mynetwork, my_tariffs, results, status_callback=None) results.set_retailer_grid_import_revenue_fixed(time, total_fixed) results.set_retailer_grid_import_revenue_variable(time, total_variable) results.set_retailer_local_solar_import_revenue(time, total_local_solar) + # print("LUKE RETAIL CENTRAL BATTERY 'income'", my_tariffs.get_retail_income_on_central_batt_import(time)) + # print("LUKE RETAIL CENTRAL BATTERY 'gross participant central import'", gross_participant_central_battery_import) results.set_retailer_central_battery_import_revenue(time, my_tariffs.get_retail_income_on_central_batt_import(time) * gross_participant_central_battery_import) total_retailer_revenue = results.get_retailer_grid_import_revenue_fixed(time) + results.get_retailer_grid_import_revenue_variable(time) + results.get_retailer_local_solar_import_revenue(time) + results.get_retailer_central_battery_import_revenue(time) results.set_retailer_total_revenue(time, total_retailer_revenue) diff --git a/Flask/application/modelling/luomi_model/tariffs.py b/Flask/application/modelling/luomi_model/tariffs.py index e4526a7..987fd4c 100644 --- a/Flask/application/modelling/luomi_model/tariffs.py +++ b/Flask/application/modelling/luomi_model/tariffs.py @@ -45,7 +45,7 @@ def get_local_solar_import_tariff(self, date_time): """ The amount which the Participant pays for local solar they consume. """ - local_solar_import_tariff = float(self.config['local_solar']['energy']) + float(self.config['local_solar']['retail']) + float(self.config['local_solar']['duos']) + local_solar_import_tariff = float(self.config['local_solar']['energy']) + float(self.config['local_solar']['retail']) + float(self.config['local_solar']['duos']) + float(self.config['local_solar']['tuos']) return local_solar_import_tariff @@ -64,7 +64,15 @@ def get_central_batt_tariff(self,date_time): def get_central_batt_buy_tariff(self,date_time): """This is the tariff paid by the participant to the battery when consuming battery export electricity.""" """Input in UI""" - participant_central_battery_import_tariff = float(self.config['central_battery']['energy']) + float(self.config['central_battery']['retail']) + float(self.config['central_battery']['duos']) + float(self.config['central_battery']['profit']) + participant_central_battery_import_tariff = float(self.config['central_battery']['energy']) + float(self.config['central_battery']['retail']) + float(self.config['central_battery']['duos']) + float(self.config['central_battery']['tuos']) + float(self.config['central_battery']['nuos']) + float(self.config['central_battery']['profit']) + # print(self.config['central_battery']) + # print("energy", self.config['central_battery']['energy']) + # print("retail", self.config['central_battery']['retail']) + # print("duos", self.config['central_battery']['duos']) + # print("tuos", self.config['central_battery']['tuos']) + # print("nuos", self.config['central_battery']['nuos']) + # print("profit", self.config['central_battery']['profit']) + # print(participant_central_battery_import_tariff) return participant_central_battery_import_tariff