diff --git a/Utilities/BESS.py b/Utilities/BESS.py index fa46610..96b7505 100644 --- a/Utilities/BESS.py +++ b/Utilities/BESS.py @@ -31,7 +31,7 @@ def discharge_bess(bess, site_name, dt, discharge_power): continue if unit["site"] == site_name: - new_soc = unit["SoC"] - (dt * discharge_energy) / unit["capacity_kWh"] + new_soc = unit["SoC"] - discharge_energy / unit["capacity_kWh"] new_soc = 0 if new_soc < 0 else new_soc else: continue diff --git a/Utilities/DataVis.py b/Utilities/DataVis.py index 9ed6012..6f64c6b 100644 --- a/Utilities/DataVis.py +++ b/Utilities/DataVis.py @@ -26,6 +26,11 @@ def format_dataframe( current_load = bess_data["units"][index]["current_load_kW"] unit_name = bess_data["units"][index]["name"] predicted_swap_time = swap_time.get(unit_name, "N/A") + # convert predicted_swap_time to a readable format + if isinstance(predicted_swap_time, float): + predicted_swap_time = pd.to_datetime( + predicted_swap_time, unit="s" + ).strftime("%Y-%m-%d %H:%M:%S") status_df = pd.concat( [ diff --git a/dashboard.py b/dashboard.py index af7f1e9..734e0f3 100644 --- a/dashboard.py +++ b/dashboard.py @@ -63,7 +63,7 @@ def show_table(): "SoC (%)": st.column_config.ProgressColumn( "State of Charge", help="State of Charge of the BESS unit", - format="%d%%", + format="%.1f%%", min_value=0, max_value=100, ), @@ -84,9 +84,20 @@ def show_table(): if st.session_state.running: + # display simulation start time + st.metric( + "Simulation Start Time", + value=pd.to_datetime(main.c["sim_start_time"], unit="s").strftime( + "%Y-%m-%d %H:%M:%S" + ), + ) + st.metric( + "Time Elapsed in DD:HH:MM:SS", + value=str(pd.to_timedelta(main.sim_i * main.dt, unit="s")), + ) # display BESS data, SoC, Load Consumption show_table() - time.sleep(1) + time.sleep(3) st.rerun() else: show_table() diff --git a/main.py b/main.py index 8ac36bd..6bb3093 100644 --- a/main.py +++ b/main.py @@ -126,7 +126,7 @@ def simulation_loop(): ) # small sleep to allow dashboard to refresh / release GIL - time.sleep(1) + time.sleep(0.1) ### <<< CONTROL ADDED >>> Control functions