forked from lianghu83/Electric-vehicle-energy-consumption
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driving_cycles.R
49 lines (39 loc) · 1.25 KB
/
driving_cycles.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
### driving cycles from EPA
#change driving cycle and distance here
path <- "https://www.epa.gov/sites/production/files/2015-10/"
#UDDS, city driving conditions, light-duty vehicles
dc <- "uddscol"
distance <- 7.45 #miles
#FTP, EPA75
dc <- "ftpcol"
distance <- 11.04 #miles
#HWFET, highway driving conditions under 60 mph
dc <- "hwycol"
distance <- 10.26 #miles
#NYCC, low speed stop-and-go traffic conditions
dc <- "nycccol"
distance <- 1.18 #miles
#US06, high accleration aggressive driving schedule that is often identified as Supplement FTP driving schedule
dc <- "us06col"
distance <- 8.01 #miles
#the driving cycle file
df <- read.table(paste0(path, dc, '.txt'), sep="\t", header=F, skip=2)
colnames(df) <- c('Time', 'Speed.mph')
df$S <- round(df$Speed.mph*0.44704, 4) #m/s
acc <- round(diff(df$S), 4)
df$A <- append(acc, 0, after=length(acc)) #unit: m/s/s
df$S2 <- df$S^2
df$S3 <- df$S^3
df$SA <- df$S*df$A
df$S2A <- df$S^2*df$A
df$S3A <- df$S^3*df$A
df$A2 <- df$A^2
df$SA2 <- df$S*df$A^2
df$S2A2 <- df$S^2*df$A^2
df$S3A2 <- df$S^3*df$A^2
df$A3 <- df$A^3
df$SA3 <- df$S*df$A^3
df$S2A3 <- df$S^2*df$A^3
df$S3A3 <- df$S^3*df$A^3
#write
write.csv(df, file=paste0('H:\\Driving cycles\\', dc, '.csv'), row.names=F)