Skip to content

Instantly share code, notes, and snippets.

@AIAnytime
Created April 13, 2024 11:33
Show Gist options
  • Save AIAnytime/f6e712aa722b30997b23c1eea55f744e to your computer and use it in GitHub Desktop.
Save AIAnytime/f6e712aa722b30997b23c1eea55f744e to your computer and use it in GitHub Desktop.
carbon sci
import streamlit as st
# App title
st.title('EcoOptimizer Carbon Footprint Calculator')
# Introduction
st.write('''
This tool calculates the Software Carbon Intensity (SCI) for EcoOptimizer,
an AI-powered energy management system for commercial buildings by EcoTech Solutions.
''')
# Inputs with default values from the case study
st.header('Input the following details:')
E = st.number_input('Energy consumed per transaction (E in kWh):', value=0.05, format="%.2f")
I = st.number_input('Carbon intensity of the energy (I in kg CO₂e per kWh):', value=0.4, format="%.2f")
M = st.number_input('Embodied carbon of the hardware (M in kg CO₂e):', value=200.0, format="%.2f")
R = st.number_input('Functional unit (Transactions processed per 1,000):', value=1000, format="%d")
# Calculation Button
if st.button('Calculate Software Carbon Intensity (SCI)'):
days_in_service_life = 365 * 3 # 3 years
daily_E = E * (R / 1000) # Daily energy consumption for R transactions
daily_emissions = daily_E * I # Daily operational emissions
daily_embodied_emissions = M / days_in_service_life # Daily share of embodied carbon
SCI = daily_emissions + daily_embodied_emissions
st.subheader('Calculated SCI:')
st.write(f'{SCI:.3f} kg CO₂e per day for {R} transactions')
st.write('This measurement provides insight into the carbon footprint of your software, aiding in identifying areas for improvement and reduction.')
else:
st.write('Enter the values and click calculate.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment