For a personal hobby project, I'm trying to figure out how much it would cost to switch Cleveland, Ohio, to fully renewable electricity for a single day in July (any July). I'm trying to use cvxpy to do this, because it seems like a minimization problem (trying to minimize cost). I've collected data in a rather amateur-ish way from Googling various things. Some highlight numbers from my research: I think Cleveland needs about 481 GWh to get through the day. A kilowatt of wind costs $1300, a kilowatt of solar costs $300, and a kilowatt-hour of lithium-ion battery costs $153.
In my current plan, I randomly decide whether the day is cloudy or not, and I randomly decide the wind speed. I model the sunlight as a sine wave (only the positive half). I plan to rely on multiple runs of the minimizer to get a sense of the various combinations that can arise (from cloudy and wind-still to bright and windy). I hand-picked the numbers for the hour-by-hour electricity requirement for the city. The electricity requirement kind of looks like a sine wave.
My code is here: https://github.com/benswitala/SolarWindBattery/edit/main/main.py
My problem is that I think I'm getting fishy results. For one thing, the code frequently seems to output either negative wind capacity or negative solar capacity (although these values are always small, quite close to zero). This is in spite of a constraint that I put that the wind capacity and solar capacity should always be 0 or higher. The second problem is that if I provide the city with a full battery of 481 GWh at midnight at the beginning of the day, I would expect the optimizer to completely eschew any solar and wind capacity and just rely on the energy I provided at the beginning. So, what gives?
If you have any interest in this project, please do let me know if you have any insights or experience to share with me. I have only used cvxpy once before, for a school project, and I was only somewhat successful in that case.
Here are the constraints that I think may be the culprit: for i in range(24): constraints += [battery_capacity >= energy_in_battery[i]]
constraints += [energy_in_battery[i] >= cuyahoga_county_energy_requirement[i]]
if i == 0:
constraints += [energy_in_battery[i] == today_wind_speed * wind_cp * wind_power_capacity +
solar_power_capacity * cloudy_factor * sun[i] + starting_energy
- cuyahoga_county_energy_requirement[i]]
else:
constraints += [energy_in_battery[i] == today_wind_speed * wind_cp * wind_power_capacity +
solar_power_capacity * cloudy_factor * sun[i] + energy_in_battery[i - 1]
- cuyahoga_county_energy_requirement[i]]
Thanks, Ben
I've tried re-arranging my constraints and expressing them in different ways, but that has not worked so far.