# Understanding Degree Days

The degree day system predicts heating fuel consumption based on outdoor temperature. It's commonly used for automatic oil delivery scheduling to estimate when a customer will need a refill.

---

## What is a degree day?

A **degree day** measures heating demand:

- **Heating Degree Day (HDD)**: Measures how cold it is relative to a base temperature (usually 65°F)
- **Calculation**: For each day, HDD = max(0, Base Temp - Average Outdoor Temp)
- **Accumulation**: Sum HDDs over time to estimate fuel consumption

**Example**:

- Base temperature: 65°F
- Average outdoor temperature: 40°F
- HDD for that day: 65 - 40 = 25 HDD

If it takes 5 HDD to burn 1 gallon of oil (K-factor = 5), then after 100 accumulated HDD, the customer has used approximately 20 gallons.

---

## Key formulas

### Daily heating degree days

$$
HDD_{day} = \max(0, T_{base} - T_{avg})
$$

Where:

- $T_{base}$ = Base temperature (typically 65°F)
- $T_{avg}$ = Average outdoor temperature for the day

### Accumulated degree days

$$
HDD_{accumulated} = \sum_{i=1}^{n} HDD_i
$$

Sum all daily HDDs since the last delivery.

### K-factor (consumption rate)

The K-factor represents the relationship between degree days and gallons consumed:

$$
K = \frac{HDD}{gallons}
$$

**Example**: If a customer used 200 gallons over 1000 HDD, then:

$$
K = \frac{1000}{200} = 5.0
$$

So it takes 5 HDD to consume 1 gallon.

### Estimating gallons used

$$
gallons_{used} = \frac{HDD_{accumulated}}{K}
$$

### Remaining fuel estimate

$$
remaining = capacity - gallons_{used}
$$

Where capacity is the effective tank capacity (total capacity minus a reserve buffer).

### Triggering a delivery

Dispatch a delivery when:

$$
remaining \leq reserve_{threshold}
$$

Typically, reserve threshold is 25-30% of capacity to avoid run-outs.

---

## Configuration steps

### 1. Set base temperature

- **Standard**: 65°F for most residential heating
- **Adjustments**: Some buildings may use 60°F or 68°F based on insulation, thermostat settings, or climate
- **Configuration**: Set at the service or system level

### 2. Determine K-factor

**Initial K-factor** (before delivery history):

- Use industry defaults: 4.0–6.0 for typical homes
- Adjust based on building type:
  - Well-insulated modern homes: 6.0–8.0 (higher K = less consumption per HDD)
  - Older, poorly insulated: 3.0–4.5
  - Commercial buildings: Varies widely; consult historical data or energy audit

**Computed K-factor** (after deliveries):

- After 2-3 deliveries, compute K-factor from actual consumption:
  - Gallons delivered = amount filled
  - HDD accumulated = sum of degree days between deliveries
  - $K = \frac{HDD}{gallons}$
- Update the service's K-factor with the computed value for better accuracy

### 3. Initialize the system

On the first delivery (or when setting up):

- **Last delivery date**: Date of most recent fill
- **Last delivery amount**: Gallons delivered
- **Starting tank level**: Estimated gallons remaining before the delivery (if known)

The system will start accumulating degree days from the last delivery date.

### 4. Set minimum days between deliveries

Prevent too-frequent deliveries by setting a minimum interval (e.g., 14 or 21 days). Even if degree day projections suggest a delivery is needed, the system will wait until the minimum interval passes.

### 5. Set trigger thresholds

Define when to dispatch:

- **Reserve threshold**: Gallons or percentage remaining (e.g., 25% or 75 gallons for a 275-gallon tank)
- **Lookahead days**: Optional; trigger delivery if projection shows run-out within X days

---

## Example scenario

- **Customer**: Residential, 275-gallon oil tank
- **Base temp**: 65°F
- **K-factor**: 5.0 (initial estimate)
- **Last delivery**: January 1, filled 200 gallons
- **Effective capacity**: 250 gallons (reserve 25 gallons)
- **Reserve threshold**: 75 gallons

**Degree day accumulation** (simplified):

- Jan 1–15: 300 HDD
- Estimated gallons used: 300 / 5 = 60 gallons
- Remaining: 250 - 60 = 190 gallons (above threshold, no delivery yet)

- Jan 16–31: Another 300 HDD (total 600 HDD)
- Estimated gallons used: 600 / 5 = 120 gallons
- Remaining: 250 - 120 = 130 gallons (still above 75-gallon threshold)

- Feb 1–15: Another 300 HDD (total 900 HDD)
- Estimated gallons used: 900 / 5 = 180 gallons
- Remaining: 250 - 180 = 70 gallons (**below 75-gallon threshold**)
- **Trigger delivery**

---

## Degree day data sources

- **National Weather Service (NWS)**: Historical and forecast degree days
- **NOAA**: Free weather data APIs
- **Third-party services**: Commercial degree day providers with regional accuracy
- **Internal tracking**: Some systems calculate degree days from local weather station data

Your system may automatically pull degree day data but at any time you can update or modify it.

---

## Improving accuracy

### We Recompute K-factor regularly

- After each delivery, our system automatically recalculates K-factor and uses rolling averages of the last 3-5 deliveries to smooth out anomalies (e.g., vacations, extreme weather).

### Adjust for customer behavior

- **Vacation adjustments**: If a customer is away, consumption drops; this should be noted within the customer account or routing notes to avoid under-delivery
- **Building changes**: New insulation, windows, or equipment can alter K-factor significantly

### Combine with monitors

- If a tank monitor is installed, use **both** degree day projections and real-time level data
- Degree day provides a forecast; monitor provides ground truth
- If monitor reading diverges from degree day estimate, adjust K-factor or investigate consumption anomalies

See: [Monitoring Guide](./monitoring.md)

---

## Troubleshooting common issues

### Projections are too conservative (deliveries too frequent)

- **Cause**: K-factor is too low (overestimating consumption)
- **Fix**: Increase K-factor based on actual delivery history

### Projections are too aggressive (customer runs out)

- **Cause**: K-factor is too high (underestimating consumption)
- **Fix**: Decrease K-factor; consider lowering reserve threshold

### Degree days don't match consumption

- **Cause**: Weather data source is not local enough, or customer behavior changed
- **Fix**: Use more localized weather data by changing the weather location within the admin settings.

### Sudden change in usage

- **Cause**: Equipment failure, thermostat adjustment, occupancy change, or building modification
- **Fix**: Investigate and adjust K-factor or note the anomaly; monitor closely

---

## Related guides

- [Window Strategies](./window-strategies.md) — Add time-of-day constraints to degree day deliveries
- [Calendar Scheduling](./calendar-system.md) — Combine recurring schedules with degree day
- [Monitoring](./monitoring.md) — Use monitors to validate degree day estimates
- [Add Services](../add-services.md) — Apply degree day strategy to services
- [Adding Equipment](./adding-equipment.md) — Track tank capacity for accurate projections