plot.material: spline fit and plotting material permittivities

Description Usage Arguments Value Author(s) References Examples

Description

plots raw data, and fit, returns invisible raw data, and fine interpolation

Usage

1
fit.material(material = AuJChristy, all = FALSE, draw= TRUE, range.lambda = c(0.2, 2), fine.n = 200)

Arguments

material

string

all

all range?

draw

plot?

range.lambda

range

fine.n

number of points in spline fit

Value

list

raw.data

lambda , epsilon, nk

fine.sample

lambda , epsilon, nk

...

Author(s)

baptiste auguie

References

luxpop

Examples

 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
# library(constants)
# data(luxpop)
# plot.material() -> test
# data(AuJChristy)
# plot.material("AuJChristy",range.lambda = c(0.4, 1), draw=FALSE) -> gold
# 
# subset<- sort(sample(length(gold$fine.sample$lambda), 20))
# small.sample <-as.data.frame(gold$fine.sample)[subset,]
# str(small.sample)
# with(small.sample,plot(lambda,Re(epsilon)))

## Not run: 
require(constants)
require(baptMisc)
require(ggplot2)
# clr()
data(AuJChristy) # load some permittivity values
gold <- fit.material(AuJChristy, range=c(0.4, 1), draw=F)

p0.basic <- c(1.5, 1.3, 1.54)

model.basic <- function(p, lambda=gold$fine.sample$lambda*1e-6){
	epsilon <- drude(lambda=lambda, interband=FALSE, basic=TRUE, surf=FALSE, 
		omega.p = p[1]*1e+16, 
		gamma.p = p[2]*1e+14,
		eps.inf=p[3])
		data.frame(lambda=lambda*1e6, epsilon=epsilon, nk=sqrt(epsilon))
}

obj.basic <- function(p, restrict=c(0.7, 1.2)){
 data.restrict <- subset(gold$fine.sample, isIn(restrict, lambda)  )
	model <- model.basic(p, lambda=data.restrict$lambda*1e-6)
	sos.real <- sum( (Re(model$epsilon) - Re(data.restrict$epsilon))^2 ) / max(abs(Re(data.restrict$epsilon)))
	sos.imag <- sum( (Im(model$epsilon) - Im(data.restrict$epsilon))^2 ) / max(abs(Im(data.restrict$epsilon)))
	sos <-  sos.real + sos.imag
	sos
}

res.basic <- optim(p0.basic, obj.basic)
fit.basic <- model.basic(res.basic$par)

mdrude <- material2plot(fit.basic)
gold$qplot+layer(data=mdrude$meltdf, mapping = aes(colour = variable), geom = c("line"), 
                stat = "identity")

## End(Not run)

constants documentation built on May 31, 2017, 2:25 a.m.