Usage Arguments Value Examples
1 2 3 4 |
lambda |
|
omega |
|
omega.p |
|
gamma.p |
|
basic |
|
surf |
|
interband |
|
eps.inf |
ionbackground |
nu.f |
|
leff |
surface scattering |
...
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 50 51 52 53 54 55 56 57 58 59 60 | library(constants)
data(AuJC)
gold.raw <- predict.material(AuJC, range=c(0.7, 1.2)) # original values for fit
gold <- predict.material(AuJC, range=c(0.3, 1.2), n=500) # interpolated values in wider range
model <- function(p, lambda=gold$wavelength){
epsilon <- drude(lambda=lambda*1e-6, # in meters
interband=FALSE, basic=TRUE, surf=FALSE,
omega.p = p[1]*1e+16,
gamma.p = p[2]*1e+14,
eps.inf=p[3])
data.frame(wavelength=lambda, epsilon=epsilon)
}
objective <- function(p){
model <- model(p, lambda=gold.raw$wavelength)$epsilon
sos.real <- sum( (Re(model) - Re(gold.raw$epsilon))^2 ) / sum(Re(gold.raw$epsilon)^2)
sos.imag <- sum( (Im(model) - Im(gold.raw$epsilon))^2 ) / sum(Im(gold.raw$epsilon)^2)
sos <- sos.real + sos.imag
sos
}
p0 <- c(1, 1, 1)
guess <- model(p0)
res <- optim(p0, objective)
fit <- model(res$par)
splitComplex <- function(d){
transform(d, real=Re(epsilon), imag=Im(epsilon))
}
comparison <- lapply(list(raw=gold.raw,
data=gold,
guess=guess,
fit=fit), splitComplex)
## Not run:
library(ggplot2)
m <- melt(comparison[-1], meas=c("real", "imag"))
str(m)
ggplot(m, aes(wavelength, value)) +
facet_grid(variable~., scales="free_y")+
geom_path(aes(colour=L1)) +
geom_point(data=melt(comparison[1], meas=c("real", "imag"))) +
ylab(expression(epsilon)) +
xlab(expression(wavelength*" / "*mu*m)) +
scale_colour_discrete("") +
theme_bw()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.