-
Notifications
You must be signed in to change notification settings - Fork 0
/
imp_gen.go
93 lines (81 loc) · 2.36 KB
/
imp_gen.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// imp_gen
// NOTE: Generated mcr files need to be copy and pasted into CH Instrument's
// software since we are currently NOT writing the first byte to the file.
package main
import "fmt"
import "flag"
import "os"
//import "strconv"
func main() {
// What do we want to know?
// NOTE: These are all pointers to the value, so use * to dereference it.
ocp := flag.Float64("ocp", 0.0, "open circuit potential (starting V)")
pstep := flag.Float64("pstep", 0.05, "potential value to increment/decrement (in V)")
steps := flag.Int("steps", 4, "number of steps above and below the OCP")
flag.Parse()
// fmt.Println(*ocp)
// fmt.Println(*pstep)
// fmt.Println(*steps)
// Print header
printHeader()
// Set folder
cwd, _ := os.Getwd()
fmt.Println("folder:", cwd)
fmt.Println("fileoverride")
fmt.Println()
// Set base settings
printBaseSettings()
// Generate our potentials
potentials := make([]float64, 0)
potentials = append(potentials, *ocp)
var last float64
for i := 0; i < *steps; i++ {
last = potentials[len(potentials)-1]
potentials = append(potentials, last+*pstep)
}
// Add back in OCP again to "reset" the electrode
potentials = append(potentials, *ocp)
for i := 0; i < *steps; i++ {
last = potentials[len(potentials)-1]
potentials = append(potentials, last-*pstep)
}
//fmt.Println(potentials)
// Loop around the OCP and print out each run
for i, p := range potentials {
printRun(p, fmt.Sprintf("%02d", i))
fmt.Println("delay: 10 ;s")
fmt.Println()
}
}
func printHeader() {
header :=
`# Impedance measurements as a function of potential
# ==============================================================
# WARNING: Do not edit this file directly in a text editor since
# the first 4 bytes of the file specifies the total number of
# subsequent bytes to read. This must be calculated after each
# file save. Use the generation script or edit inside of CHI.
# NOTE: text after ; on any line is interpreted as comment
`
fmt.Println(header)
}
func printBaseSettings() {
base :=
`# Base technique settings
tech: imp
fh: 100000 ;Hz
fl: 0.1 ;Hz
amp: 0.005 ;V
qt: 2 ;s, quiet time
impautosens
impsf ;single frequency measurements
# will leave the rest as default
`
fmt.Println(base)
}
func printRun(potential float64, name string) {
fmt.Printf("ei: %.3f ;V\n", potential)
fmt.Println("run")
fmt.Println("save =", name)
fmt.Println("tsave =", name)
}