Set Directory
getwd()
## [1] "/Users/michaelsczahor/Desktop/EISData"
setwd("/Users/michaelsczahor/Desktop/EISData")
Post-Polarization Import
fc1post=read.csv("FC1POST.csv")
fc2post=read.csv("FC2POST.csv")
Polarization Important
fc1pola=read.csv("FC1POLA.csv")
fc2pola=read.csv("FC2POLA.csv")
Pre-Polarization Data Import
fc1pre=read.csv("FC1PREPOLA.csv")
Age Data Import
agedata=read.csv("fullage.csv")
head(agedata)
## Timeh U1v U2v U3v U4v U5v Utotv Japercm Ia TinH2c
## 1 0.0000000 0.670 0.663 0.664 0.662 0.658 3.317 0.7016 70.16 25.93
## 2 0.0001564 0.670 0.663 0.663 0.662 0.659 3.317 0.7016 70.16 25.95
## 3 0.0003206 0.670 0.663 0.663 0.662 0.658 3.316 0.7017 70.17 25.94
## 4 0.0004747 0.669 0.663 0.663 0.662 0.659 3.316 0.7016 70.16 25.95
## 5 0.0006239 0.669 0.663 0.663 0.662 0.659 3.316 0.7016 70.16 25.94
## 6 0.0007942 0.670 0.663 0.663 0.662 0.659 3.317 0.7015 70.15 25.96
## ToutH2c TinAIRc ToutAIRc TinWATc ToutWATc PinAIRmbara PoutAIRmbara
## 1 38.89 41.92 51.50 53.81 55.50 1302 1270
## 2 38.91 41.91 51.49 53.82 55.50 1302 1270
## 3 38.90 41.91 51.51 53.80 55.50 1302 1270
## 4 38.91 41.91 51.50 53.81 55.51 1302 1270
## 5 38.91 41.91 51.52 53.81 55.48 1302 1270
## 6 38.92 41.91 51.51 53.83 55.50 1302 1270
## PoutH2mbara PinH2mbara DinH2lpermn DoutH2lpermn DinAIRlpermn
## 1 1305 1292 4.799 2.115 23.04
## 2 1305 1292 4.799 2.115 23.04
## 3 1306 1293 4.801 2.115 23.04
## 4 1306 1293 4.797 2.114 23.04
## 5 1306 1293 4.797 2.116 23.04
## 6 1306 1293 4.800 2.114 23.04
## DoutAIRlpermn DWATlpermn HrAIRFCpercent Power Category
## 1 21.33 2.020 48.90 232.7 Cell1
## 2 21.33 2.019 48.90 232.7 Cell1
## 3 21.33 2.016 48.91 232.7 Cell1
## 4 21.35 2.016 48.89 232.7 Cell1
## 5 21.33 2.017 48.94 232.6 Cell1
## 6 21.33 2.016 48.92 232.7 Cell1
Open Library
library(ggplot2)
Categorize Fuel Cells
fc1post$Cell="1"
fc2post$Cell="2"
FCPOST=rbind(fc1post,fc2post)
Subset cells*
cell1=subset(agedata,Category=="Cell1")
cell2=subset(agedata,Category=="Cell2")
Remove Plus and Minus 20 Hours from EIS Time
#Fuel Cell 1 Removal
c1rm1=which((cell1$Timeh>28)&(cell1$Timeh<68))
c1rm2=which((cell1$Timeh>165)&(cell1$Timeh<205))
c1rm3=which((cell1$Timeh>328)&(cell1$Timeh<368))
c1rm4=which((cell1$Timeh>495)&(cell1$Timeh<535))
c1rm5=which((cell1$Timeh>646)&(cell1$Timeh<686))
c1rm6=which((cell1$Timeh>810)&(cell1$Timeh<850))
c1rm7=which((cell1$Timeh>990)&(cell1$Timeh<1036))
#Fuel Cell 2 Removal
c2rm1=which((cell2$Timeh>15)&(cell2$Timeh<55))
c2rm2=which((cell2$Timeh>162)&(cell2$Timeh<202))
c2rm3=which((cell2$Timeh>323)&(cell2$Timeh<363))
c2rm4=which((cell2$Timeh>485)&(cell2$Timeh<525))
yy=which((cell2$Ia<69.5)|(cell2$Ia>70.5)) #Current Outliers
cell1=cell1[-c(c1rm1,c1rm2,c1rm3,c1rm4,c1rm5,c1rm6,c1rm7),]
cell2=cell2[-c(c2rm1,c2rm2,c2rm3,c2rm4,yy),]
Clean Cell2
xx=which((cell2$Timeh>75)&(cell2$Timeh<150))
cell2=cell2[-xx,]
xxx=which((cell2$Timeh>380)&(cell2$Timeh<450))
cell2=cell2[-xxx,]
Categorize Fuel Cells For Polarization
FCPOST$Current=as.factor(FCPOST$Current)
fc1pola$Cell="1"
fc2pola$Cell="2"
FCPOLA=rbind(fc1pola,fc2pola)
FCPOLA$Timeh=as.factor(FCPOLA$Timeh)
Age Graphs
qplot(Timeh,Utotv,data=cell1,main="Fuel Cell 1 Voltage Time Series")
qplot(Timeh,Utotv,data=cell2,main="Fuel Cell 2 Voltage Time Series")+geom_smooth(method="lm")
Simple Linear Regression Models For Age Data Fuel Cell 1 and 2
lm.fit1=lm(Utotv~Timeh,data=cell1)
lm.fit2=lm(Utotv~Timeh,data=cell2)
fit2=lm(cell2$Utotv ~ 0+Timeh, offset=rep(Utotv[1], length(Utotv)),data=cell2) ##FIXED INTERCEPT!!!!
coef(fit2)
## Timeh
## -0.0002752
#####-0.0002751978
#Fuel Cell 1
plot(cell1$Timeh,cell1$Utotv,main="Fuel Cell 1 Voltage Time Series",xlab="Time in Hours",ylab="Voltage")
abline(lm.fit1,lwd=3,col="red")
#Fuel Cell 2
plot(cell2$Timeh,cell2$Utotv,main="Fuel Cell 2 Voltage Time2 Series",xlab="Time in Hours",ylab="Voltage")
abline(lm.fit2,lwd=3,col="red")
Check Thresholds for Age Testing FC2
Pinitial=cell2$Utotv[1]
Thresh1=(Pinitial-.035*Pinitial)
Thresh2=(Pinitial-.04*Pinitial)
Thresh3=(Pinitial-.045*Pinitial)
Thresh4=(Pinitial-.05*Pinitial)
Thresh5=(Pinitial-.055*Pinitial)
Scoring Data
percerror=matrix(0,5,1)
actrul=matrix(c(21.4442,194.1917,209.7127,384.328,386.7023),5,1)
actrul=actrul+550
rulpred=matrix(0,5,1)
RUL Vector
coef(lm.fit2)
## (Intercept) Timeh
## 3.288361 -0.000175
##3.2883609535-0.0001750456
Int=3.2883609535
rulpred[1,1]=(Thresh1-Int)/-0.0001750456
rulpred[2,1]=(Thresh2-Int)/-0.0001750456
rulpred[3,1]=(Thresh3-Int)/-0.0001750456
rulpred[4,1]=(Thresh4-Int)/-0.0001750456
rulpred[5,1]=(Thresh5-Int)/-0.0001750456
```r
for(i in 1:5){
percerror[i]=100*(actrul[i]-rulpred[i])/actrul[i]}
percerror
## [,1]
## [1,] 20.29
## [2,] 26.03
## [3,] 15.04
## [4,] 20.75
## [5,] 10.81
##Good performance Relates to early predictions
##Poor performance Relates to late predictions
e=exp(1)
AFT=matrix(0,5,1)
for(i in 1:5){
if(percerror[i,1]<0){
AFT[i]=exp(-log(.5)*(percerror[i,1]/5))
}
else{
AFT[i]=exp(log(.5)*(percerror[i,1]/20))
}
}
Score1=sum(AFT)/5
Score1
## [1] 0.5338
#University Score .7760
#Industry Score .3592
RUL Vector First Reading Intercept Calculation
coef(fit2)
## Timeh
## -0.0002752
#-0.0002751978
Int=cell2$Utotv[1]
rulpred[1,1]=(Thresh1-Int)/-0.0002751978
rulpred[2,1]=(Thresh2-Int)/-0.0002751978
rulpred[3,1]=(Thresh3-Int)/-0.0002751978
rulpred[4,1]=(Thresh4-Int)/-0.0002751978
rulpred[5,1]=(Thresh5-Int)/-0.0002751978
```r
for(i in 1:5){
percerror[i]=100*(actrul[i]-rulpred[i])/actrul[i]}
percerror
## [,1]
## [1,] 26.00
## [2,] 35.06
## [3,] 28.43
## [4,] 35.34
## [5,] 29.06
##Good performance Relates to early predictions
##Poor performance Relates to late predictions
e=exp(1)
AFT=matrix(0,5,1)
for(i in 1:5){
if(percerror[i,1]<0){
AFT[i]=exp(-log(.5)*(percerror[i,1]/5))
}
else{
AFT[i]=exp(log(.5)*(percerror[i,1]/20))
}
}
Score2=sum(AFT)/5
Score2
## [1] 0.347
#University Score .7760
#Industry Score .3592