Charging Habits for Electric Vehicles

Nicholas Schettini

July 26, 2018

library(tidyverse)
library(knitr)
library(psych)
library(readr)
library(kableExtra)
library(ggiraph)
library(cowplot)
library(reshape2)
library(corrgram)
library(gridExtra)
library(lubridate)
library(magrittr)
library(scales)
library(ggthemes)
library(forcats)

This supplements the Presentation located on Github at the following address:

Charging Habits for Electric Vehicles

Electric Vehicles are becoming ever more popular for consumers, especially within large cities like New York. Electriv vehicles help consumers in many ways - from reducing their carbon footprint, eliminating oil changes (on full electric vehicles), to saving money. Electric vehicles are becoming cheaper to purchase, and also able to travel further on a single charge.

However, with the increase in electric vehicles, companies that supply the electricity that powers these vehicles are facing new challenges.

Understanding when and how much these electric vehicles are being charged is a fundamental aspect of being able to supply reliable energy effectively.

According to fleetcarma, a typical EV with a communting distance of around 25miles requires 6-8 kWh of energy, which is roughly equal to the daily need of a small home. Power transformers, which connect homes and businesses to the grid at a local level, are only able to handle a certain threshold. In the future, if multiple EVs are charging at the same time on the same local transformer, this could cause potential problems with overloading and potential outages.

The risk of overloading local transformers is higher during peak hours - which is why it’s important to understand when consumers are charging their EVs.

head(energy)
## # A tibble: 6 x 5
##   CustomerID Energy_WattHours Date       Time   Vehicle
##        <int>            <dbl> <chr>      <time> <chr>  
## 1          1                0 06-01-2015 00'00" <NA>   
## 2          1                0 06-01-2015 05'00" <NA>   
## 3          1                0 06-01-2015 10'00" <NA>   
## 4          1                0 06-01-2015 15'00" <NA>   
## 5          1                0 06-01-2015 20'00" <NA>   
## 6          1                0 06-01-2015 25'00" <NA>
energy$Date <- as.Date(energy$Date, "%m-%d-%Y")

energy$Month <- as.Date(cut(energy$Date, breaks = "month"))
energy$Week <- as.Date(cut(energy$Date, breaks = "week", start.on.monday = F))
data <- energy
data %<>% mutate(timeofday = hour(energy$Time) + minute(energy$Time)/60) # seperate time of day
data %<>% mutate(weekday = wday(energy$Date, label = T)) # seperate day of week
data1 <- energy
data1$Time <- hms(as.character(data1$Time))
data1$time_of_day <- hour(data1$Time)
data1$weekday <- wday(data1$Date)

Total kWh by Time of Day

ggplot(data = data, aes(data$timeofday, data$Energy_WattHours)) + 
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill=sum(data$Energy_WattHours))) +
  ggtitle("Total kWh by Time of Day") +
  xlab("Hour") +
  ylab("Total Energy Watt Hours") +
  theme(legend.position="none") +
  scale_y_continuous(labels = comma)

ggplot(data = data1, aes(data1$time_of_day, data1$Energy_WattHours)) + 
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill=sum(data1$Energy_WattHours))) +
  ggtitle("Total kWh by Time of Day for Summer 2015") +
  xlab("Hour") +
  ylab("Total Energy Watt Hours") +
  theme_fivethirtyeight() +
  theme(legend.position="none") +
  scale_y_continuous(labels = comma) 

model <- lm(data1$Energy_WattHours ~ (data1$time_of_day), data = data1)
anova(model)
## Analysis of Variance Table
## 
## Response: data1$Energy_WattHours
##                        Df     Sum Sq  Mean Sq F value    Pr(>F)    
## data1$time_of_day       1 1.0509e+07 10508501  1086.3 < 2.2e-16 ***
## Residuals         2004176 1.9388e+10     9674                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

According to the data, it seems that time of day does have an impact on when consumers charge their electric vehicles.It looks as if consumers start charging their vehicles late in the morning, increasing until around 12am, when charging slowly decreases.

offpeak <- with(data1, data1[(data1$time_of_day) >= 0 & (data1$time_of_day) < 9,])

Offpeak hours for Summer 2015

ggplot(data = offpeak, aes(offpeak$time_of_day, offpeak$Energy_WattHours)) + 
  stat_summary(fun.y = mean,
               geom = "density", fill="light blue") +
  ggtitle("Total kWh - Off-peak Summer 2015") +
  theme_fivethirtyeight() +
  xlab("Hour") +
  ylab("Total Energy Watt Hours") +
  theme(legend.position="none") +
  scale_y_continuous(labels = comma) 

Filtering by off-peak only, we can see a downward slope. Over the course of the summer of 2015, electric vehicles are charged at their highest around 12am, and drop off closer to 8am.

Peak hours for Summer 2015

peak <- with(data, data1[(data1$time_of_day) >= 9 & (data1$time_of_day) <= 23,])
ggplot(data = peak, aes(peak$time_of_day, peak$Energy_WattHours)) + 
  stat_summary(fun.y = mean,
               geom = "density", fill="light blue") +
  theme_fivethirtyeight() +
  ggtitle("Total kWh - Peak for summer 2015") +
  xlab("Hour") +
  ylab("Total Energy Watt Hours") +
  theme(legend.position="none") +
  scale_y_continuous(labels = comma) 

Looking at peak hours, charging begins to ramp up after the off-peak hours.

Day of the week for Summer 2015

ggplot(data, aes(data$weekday)) + 
  geom_bar(aes(fill=data$weekday)) +
  ggtitle("Count of 2015 Summer Weekly Charges") +
  scale_y_continuous(labels = comma) +
  xlab("Weekday") +
  guides(fill=guide_legend(title="Weekday"))

ggplot(data = data, aes(data$weekday, data$Energy_WattHours)) +
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill = as.factor(weekday))) +
  theme_dark() +
  scale_y_continuous(labels = comma) +
  ylab("Total Energy Watt Hours") +
  xlab("weekday") +
  ggtitle("Total Energy Watthours for Summer 2015") +
  guides(fill=guide_legend(title="Month"))

model2 <- lm(data1$Energy_WattHours ~ (data1$weekday), data = data1)
anova(model2)
## Analysis of Variance Table
## 
## Response: data1$Energy_WattHours
##                    Df     Sum Sq Mean Sq F value    Pr(>F)    
## data1$weekday       1 1.5302e+06 1530216  158.11 < 2.2e-16 ***
## Residuals     2004176 1.9397e+10    9678                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The day of the week also seems to have an impact on when people are charging their vehicles. The most charging seems to take place on a Tuesday, followed by Monday. While the least charging seems to take place on Thursday and Friday.

Summer Months of 2015

ggplot(data = energy, aes(energy$Month, energy$Energy_WattHours)) +
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill = as.factor(Month))) +
  theme_dark() +
  scale_y_continuous(labels = comma) +
  ylab("Total Energy Watt Hours") +
  xlab("Month") +
  ggtitle("Total Energy Watthours for Summer 2015") +
  guides(fill=guide_legend(title="Month"))

model3 <- lm(data1$Energy_WattHours ~ (data1$Month), data = data1)
anova(model3)
## Analysis of Variance Table
## 
## Response: data1$Energy_WattHours
##                  Df     Sum Sq Mean Sq F value    Pr(>F)    
## data1$Month       1 1.1538e+06 1153814  119.21 < 2.2e-16 ***
## Residuals   2004176 1.9397e+10    9678                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The months with the most kWhs are June, July, followed by Sep and Aug.

Consumer Education

Having consumers switch to charging their vehciles during off-peak hours makes sense. It helps to reduce load during the busiest times of the day, and helps prevent damage from occuring to transformers.

Consumers can be persuaded to charge overnight with certain rewards - such as price. Lower prices for charging during off-peak, or a reward system can help prevent charging during peak hours.

Partnerships with dealers

Many electric cars are also “smart” - meaning, a schedule can be set in the vehicle to begin charging. Dealerships can pre-program, and work with consumers, to have energy efficent scheudles programmed before the car leaves the dealership.

The Future

Charging at off-peak hours only can lead to potential problems in the future (when more EVs are common in neighborhoods). Transformers are designed to ‘cool-off’ during the night, and with multiple EVs charging at the same time at night, problems from charging during peak hours start to happen again.

This is where smart, or managed, charging comes in. Smart meters are able to determine how much energy is being used in an area. When energy consumption is low, vehicles can be set to begin charging. When energy consumption is high, charging stops.

This is similar to how a Nest thermostat works with Con Edison to help save energy during ‘rush hour’ events.

Habits of Consumers

data_consumer1 <- data %>%
   group_by(CustomerID) %>%
  select(CustomerID, Energy_WattHours, timeofday) %>%
  summarize(n=n()) %>%
  arrange(desc(n))


data_consumer <- data


ggplot(data = data_consumer, aes(data_consumer$CustomerID, data_consumer$Energy_WattHours)) +
  stat_summary(fun.y = sum,
               geom = "bar", 
               aes(fill = as.factor(timeofday)) ) +
  theme_dark() +
  scale_y_continuous(labels = comma) +
  ylab("Total Energy Watt Hours") +
  xlab("Month") +
  ggtitle("Total Energy Watthours for Summer 2015") +
  theme(legend.position="none")

Some consumers charge more than others, as shown in the above graph. Consumers that are charging the most during peak hours should be reminded of the benefits for charging during off-peak times.

ggplot(data = data, aes(data$Date, data$Energy_WattHours)) + 
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill=as.factor(data$weekday))) +
  theme_dark() +
  ggtitle("Total kWh by Month and Week") +
  xlab("Date") +
  ylab("Total Energy Watt Hours") +
  scale_y_continuous(labels = comma)

Types of Vehicles

Combine similar vehicle names:

vehicledata <- data1
vehicledata$Vehicle[vehicledata$Vehicle == "Tesla 85 KW"] <- "Tesla 85 kwh"
vehicledata$Vehicle[vehicledata$Vehicle == "Tesla 60 kW"] <- "Tesla 60 kWh"
vehicledata$Vehicle[vehicledata$Vehicle == "Tesla 85 kW"] <- "Tesla 85 kwh"
vehicledata$Vehicle[vehicledata$Vehicle == "Volt, Volt"] <- "Volt"

vehicledata$Vehicle[vehicledata$Vehicle == "Tesla 85 kWh"] <- "Tesla 85 kwh"
vehicledata$Vehicle[vehicledata$Vehicle == "Tesla 85kWh"] <- "Tesla 85 kwh"
ggplot(data = data, aes(fct_infreq(vehicledata$Vehicle), vehicledata$Energy_WattHours)) + 
  stat_summary(fun.y = sum,
               geom = "bar", aes(fill=sum(vehicledata$Energy_WattHours))) +
  ggtitle("Total kWh by Vehicle Type") +
  xlab("Vehicle") +
  ylab("Total Energy Watt Hours") +
  theme(legend.position="none") +
   theme(axis.text.x=element_text(angle=45, hjust=1)) +
  scale_y_continuous(labels = comma)

datavehicle <- na.omit(data)

vehicledata %>%
  select(Vehicle, CustomerID) %>%
  group_by(Vehicle ) %>%
  distinct() %>%
  summarize(n=n()) %>%
  arrange(desc(n))
## # A tibble: 16 x 2
##    Vehicle                             n
##    <chr>                           <int>
##  1 Volt                               14
##  2 Tesla 85 kwh                        8
##  3 <NA>                                7
##  4 Tesla 60 kWh                        6
##  5 Leaf 3.3 kW                         4
##  6 Leaf 6.6 kW                         3
##  7 Ford Cmax Energi                    2
##  8 Prius                               2
##  9 Tesla                               2
## 10 Tesla 85 KW Performance             2
## 11 Ford Fusion Energi                  1
## 12 Honda Fit                           1
## 13 Leaf                                1
## 14 Leaf 3.3 kW, Volt                   1
## 15 Leaf 3.3 kWand Ford Cmax Energi     1
## 16 Smart Car                           1

The Telsa brand in the #1 type of EV in the dataset, followed by the Volt.