-
Notifications
You must be signed in to change notification settings - Fork 0
/
smarties_batch.R
51 lines (41 loc) · 2.26 KB
/
smarties_batch.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
50
## ----eval=TRUE, message=FALSE-------------------------------------------------
library(glue)
library(dplyr)
library(purrr)
# read in the template
template <- glue_collapse(readLines('smarties/_template.m'), sep = "\n")
parameters <- expand.grid(a = seq(10, 100, by=5), c = seq(10, 100, by=5),
material = c("Au", "Ag", "Si"),
medium = c("vacuum", "water")) |>
filter(a != c) |> # use Mie for this
mutate(shape = ifelse(a > c, "oblate", "prolate"),
n = ifelse(medium == "water", 1.33, 1.0),
source = case_when(material == "Au" ~ "Raschke et al 10.1103/PhysRevB.86.235147",
material == "Ag" ~ "Raschke et al 10.1103/PhysRevB.91.235137",
material == "Si" ~ "Aspnes et al 10.1103/PhysRevB.27.985",
.default = "Unknown material!"))
parameters$step <- 1
nrow(parameters)
## ----eval=TRUE----------------------------------------------------------------
parameters <- expand.grid(a = seq(20, 50, by=10), c = seq(20, 50, by=10),
material = c("Au", "Ag"),
medium = c("water")) |>
filter(a != c) |> # use Mie for this
mutate(shape = ifelse(a > c, "oblate", "prolate"),
n = ifelse(medium == "water", 1.33, 1.0),
source = case_when(material == "Au" ~ "Raschke et al 10.1103/PhysRevB.86.235147",
material == "Ag" ~ "Raschke et al 10.1103/PhysRevB.91.235137",
material == "Si" ~ "Aspnes et al 10.1103/PhysRevB.27.985",
.default = "Unknown material!"))
parameters$step <- 5
## ----echo=FALSE---------------------------------------------------------------
gt::gt(parameters[,c("a","c","shape","material","medium")])
## -----------------------------------------------------------------------------
write_script <- function(a, c, material, medium, shape, n, step, source){
script <- glue(template)
cat(script, file = glue('smarties/run_{material}_{medium}_{a}_{c}.m'))
cat(glue("run_{material}_{medium}_{a}_{c}\n\n"),
file = "smarties/batch.m", append = TRUE)
}
cat("%% Running all the files below\n",file = "smarties/batch.m", append = FALSE)
pwalk(rowwise(parameters), write_script)