Building an Hour-by-Hour Solar Calculator
Solar pays most for the power you use as it's made. Everything sent to the grid earns less, often much less. So a solar calculator lives or dies on one question: when does your home use power, compared with when the panels make it? Mine answered that with a shortcut, and I wanted to know what the shortcut was costing.
I worked on this with Claude, Anthropic's AI model. I asked the questions and made the calls. Claude wrote the test code, ran the numbers and dug up the sources. Here's what we found.
One averaged day a month
The original engine imagined one typical day per month. Production rose and fell in a smooth curve, and the home's use was split into fixed daytime and evening shares. A battery could only discharge from 4 to 9 PM.
I suggested testing it against something closer to real life, and Claude ran the tests. NLR, the national lab once called NREL, publishes hour-by-hour simulations of homes built to match the actual housing in each county. We took 50 single-family homes in each of the calculator's 14 markets, 700 in all, and ran every one for a full year, hour by hour, against NLR's PVWatts solar data for the same place.
The averaged day under-counted the share of solar a home uses directly by 5 to 11 percentage points. It also gave west-facing roofs credit for evening hours they don't really reach, and its batteries got the evening wrong.
How much data is enough?
My first worry was size. Would a realistic engine mean a huge download for every visitor? So we tested how little data we could get away with.
The obvious move is to average: one smooth curve from many homes. It turned out to be the wrong one. Homes are lumpy. Their use jumps around and often lands outside the sunny hours. An average spreads it evenly underneath the solar, which flatters it.
Averaged curves overstated savings by 5 to 8%. What worked was keeping homes and days whole, just fewer of them. For each market, the calculator keeps five simulated homes for each of three usage patterns (out most of the day, mornings and evenings, home all day) and 10 to 15 real days per month, each standing in for a group of similar days. It runs all five homes and averages their results, never their curves.
I set the target: savings within about 2% of the full hour-by-hour answer, and the 10-year return within 0.3 percentage points (7.3% instead of a true 7.0%, say). On homes the method hadn't been tuned on, it hit that target far more often than the old engine.
And the size worry went away. Each market's files are about 25 KB, and a visitor only downloads the ones for their own market.
Ideas that came from poking at it
Electric heat. I asked what happens when you change the usage figure, since the sample homes each had their own. Claude ran it: small and medium homes were fine, but the biggest ones came out too optimistic, and nearly all of those heated with electricity. Their use piles up on winter mornings and nights, when panels make little. My idea was to keep each sample home's always-on level fixed and stretch only the rest. That halved the error. Adding a question about how you heat your home closed the gap.
The car. When I played with the beta, the car charging looked wrong to me: too fast, and too late in the day to use the sun. I proposed a rule: never charge from the grid at peak prices. The calculator now charges the way a smart charger would, from the panels when the sun is up and the rest overnight. You can switch to "charge as soon as it's plugged in" to see what that costs.
Rates. Once the engine knew the hour, rates became the weak spot. Most time-of-use plans change with the season, so the calculator now prices each hour from the real plan. The national rate database had errors: one plan priced its winter peak as off-peak on some weekdays, another had its summer peak in the wrong hours, and LADWP's prices were several cents out of date. Claude now checks each plan's hours against the utility's own rates wherever it can find them, but it isn't easy or 100% reliable with such variability in how these things are reported.
I had another AI run a quote from a Reddit post through the old calculator: 15 kW in Los Angeles for $32,000. The new engine alone changed nothing on that quote. The rates changed everything.
An idea I dropped
I also asked for an "optimize for return" button. Claude built it, and its first answer surprised us both. Under California's current export rules, a system sized to cover all of a home's use returned 1.4% a year in one test, while one about 40% of that size returned 10.7%. Exports earn so little that extra panels lose money. Since price per watt is only an estimate, and real quotes depend on much more, I decided a button like that would mislead more than help. The calculator will still show you the effect if you change the system size yourself.
What more data can't fix
Even when the calculator is right about a typical home, your home isn't typical. The middle half of the 700 test homes landed between 2% below and 3.5% above the prediction for their pattern. Your own meter readings would close that gap, so we're building a way to load your utility's Green Button download.
Try it
The new engine now runs the rooftop calculator. Pick your location and you'll see the rates and export rules it starts from, each with its source and the date it was checked. Anything we couldn't confirm, or haven't checked in over a year, is marked in red. If something looks wrong for where you live, I'd like to hear about it.