Академический Документы
Профессиональный Документы
Культура Документы
state
library(readxl)
library(utils)
library(ggplot2)
setwd("C:/Users/RicardoGC/Box Sync/Clemson/Lab Research/2020/Gamma
Alumina/Validation")
#Validation=read_excel("C:/Users/RicardoGC/Box Sync/Clemson/Lab
Research/2020/Gamma Alumina/Validation/Pt Conventional Standard Cell
Optimization (Bulk).xlsx")
Validation=read_excel("Gamma Alumina Digner Slab a Lattice
Optimization.xlsx",sheet = "GO Point Lattice")
###Find closest
closestx=function(x,value) {
which(abs(x-value)==min(abs(x-value)))
return(x[which(abs(x-value)==min(abs(x-value)))])
}
closesty=function(x,y,value) {
which(abs(x-value)==min(abs(x-value)))
return(y[which(abs(x-value)==min(abs(x-value)))])
}
###
Validation=Validation[!is.na(Validation$`Energy/Atom (eV)`),]
Validation=Validation[Validation$`Energy/Atom (eV)`<=0,]
#Validation=Validation[Validation$`Energy/Atom (eV)`<=-4,]
#Constants=[E0,B0,B0p,V0]
Constants0=c(min(Validation$`Energy/Atom
(eV)`),1,1,min(Validation$`Volume/Atom (Å3)`))
BM=function(V,E0,B0,B0p,V0) {
#E0=Constants[1]
#B0=Constants[2]
#B0p=Constants[3]
#V0=Constants[4]
E=E0+9/16*V0*B0*(((V0/V)^(2/3)-1)^3*B0p+(((V0/V)^(2/3)-1)^2*(6-
4*(V0/V)^(2/3))))
return(E)
}
#Fit model
E=y
V=x
model=nls(formula = E~BM(V,E0,B0,B0p,V0),start =
list(E0=Constants0[1],B0=Constants0[2],B0p=Constants0[3],V0=Constants0[4]
))
E_Predicted=predict(model)
Pearson_R2=cor(x = E_Predicted,y = E,method = c("pearson"))^2
Spearman_R2=cor(x = E_Predicted,y = E,method = c("spearman"))^2
Validation$E_Predicted=E_Predicted
OptimunLatticeParameter=summary(model)
$parameters[4,1]/closesty(x=Validation$`Lattice Factor`,y =
Validation$`Volume/Atom (Å3)`,value = 1)