-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathferroelectric-response.typ
242 lines (223 loc) · 6.61 KB
/
ferroelectric-response.typ
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#import "@preview/cetz:0.3.4": canvas, draw
#import draw: rect, line, circle, content, hobby, scale, set-origin
#set page(width: auto, height: auto, margin: 8pt)
#canvas({
let arrow-style = (mark: (end: "stealth", fill: black, scale: .75))
let plot-height = 4
let plot-width = 10
let y-offset = 4.5
// Helper to draw axes
let draw-axes(origin, width, height) = {
line(
(origin.at(0) - 0.3, origin.at(1)),
(origin.at(0) + width, origin.at(1)),
..arrow-style,
name: "x-axis",
)
line(
(origin.at(0), origin.at(1) - 0.3),
(origin.at(0), origin.at(1) + height),
..arrow-style,
name: "y-axis",
)
}
// Top plot: Double-well potential
let top-origin = (-5, y-offset)
draw-axes(top-origin, plot-width, plot-height)
// Draw double-well potential curve using hobby spline
hobby(
(top-origin.at(0) + .5, top-origin.at(1) + 4), // start high
(top-origin.at(0) + 1.7, top-origin.at(1) + 0.4), // left minimum
(top-origin.at(0) + 1.8, top-origin.at(1) + 0.3), // left minimum
(top-origin.at(0) + 5, top-origin.at(1) + 1.5), // up to middle peak
(top-origin.at(0) + 8.2, top-origin.at(1) + 0.3), // right minimum
(top-origin.at(0) + 8.3, top-origin.at(1) + 0.4), // right minimum
(top-origin.at(0) + 9.5, top-origin.at(1) + 4), // up high again
omega: 0,
name: "potential-curve",
stroke: 1.5pt,
)
// Add "Free Energy" label
content(
"y-axis.mid",
[Free Energy],
angle: 90deg,
anchor: "south",
padding: (0, 0, 2pt),
)
// Bottom plot: Polarization vs. displacement
let bottom-origin = (-5, 0)
draw-axes(bottom-origin, plot-width, plot-height)
// zero lines
line(
(bottom-origin.at(0), bottom-origin.at(1) + plot-height / 2),
(bottom-origin.at(0) + plot-width, bottom-origin.at(1) + plot-height / 2),
stroke: gray + 0.5pt,
)
line(
(bottom-origin.at(0) + plot-width / 2, bottom-origin.at(1)),
(bottom-origin.at(0) + plot-width / 2, bottom-origin.at(1) + plot-height),
stroke: gray + 0.5pt,
)
// Add x-axis labels
content(
(bottom-origin.at(0), bottom-origin.at(1)),
[negative],
anchor: "north-west",
padding: (4pt, 2pt, 0),
name: "neg-label",
)
content(
(bottom-origin.at(0) + 8.5, bottom-origin.at(1)),
[positive],
anchor: "north-west",
padding: (4pt, 2pt, 0),
name: "pos-label",
)
// Draw linear polarization line
line(
(bottom-origin.at(0), bottom-origin.at(1)),
(bottom-origin.at(0) + plot-width, bottom-origin.at(1) + plot-height),
stroke: blue + 1.5pt,
name: "polarization-line",
)
// Add "Polarization" and "Ti Displacement" labels
content(
"y-axis.mid",
[Polarization],
angle: 90deg,
anchor: "south",
padding: 4pt,
)
content(
"x-axis.mid",
[Ti Displacement],
anchor: "north",
padding: (10pt, 0, 0),
)
// Helper function to draw BaTiO3 unit cell
let atom(pos, radius: 0.20, fill: luma(50), ..args) = {
circle(
pos,
radius: radius,
stroke: none,
fill: fill,
..args
)
circle(
(),
radius: radius,
stroke: none,
fill: gradient.radial(
fill.lighten(75%), fill, fill.darken(15%),
focal-center: (30%, 25%),
focal-radius: 5%,
center: (35%, 30%),
),
)
}
let draw-unit-cell(center-x, center-y, ti-y, cell-name) = {
let (x, y) = (center-x, center-y)
let z-offset = -1.0 // Consistent offset for back face
let cube-style = (stroke: 0.7pt)
// Draw unit cell cube with consistent offsets
rect(
(x - 1, y - 1, 0),
(x + 1, y + 1, 0),
..cube-style,
name: cell-name + "-front",
) // Front face
line(
(x - 1, y - 1, 0),
(x - 1, y - 1, z-offset),
..cube-style,
name: cell-name + "-left",
) // Left edge
line(
(x + 1, y - 1, 0),
(x + 1, y - 1, z-offset),
..cube-style,
name: cell-name + "-right",
) // Right edge
line(
(x - 1, y - 1, z-offset),
(x + 1, y - 1, z-offset),
..cube-style,
name: cell-name + "-back",
) // Back edge
line(
(x - 1, y + 1, z-offset),
(x + 1, y + 1, z-offset),
..cube-style,
name: cell-name + "-top-back",
) // Top back edge
line(
(x - 1, y - 1, z-offset),
(x - 1, y + 1, z-offset),
..cube-style,
name: cell-name + "-left-back",
) // Left back edge
line(
(x + 1, y - 1, z-offset),
(x + 1, y + 1, z-offset),
..cube-style,
name: cell-name + "-right-back",
) // Right back edge
line(
(x + 1, y - -1),
(x + 1, y - -1, z-offset),
..cube-style,
name: cell-name + "top-right",
) // top right edge
line(
(x + -1, y - -1),
(x + -1, y - -1, z-offset),
..cube-style,
name: cell-name + "top-left",
) // top right edge
// Define helper functions for each atom style
let Ba-atom(pos, name) = atom(pos, fill: rgb("#00ffff"), name: cell-name + "-ba-" + name)
let O-atom(pos, name) = atom( pos, fill: red, name: cell-name + "-o-" + name)
let Ti-atom(pos) = atom( pos, fill: gray, name: cell-name + "-ti")
let Ti-O-bond(end-pos, name) = line(
((x, y + ti-y, z-offset/2), 15%, end-pos),
((x, y + ti-y, z-offset/2), 85%, end-pos),
stroke: 1pt,
name: cell-name + "-bond-" + name,
)
// --- Back Plane (z = z-offset) ---
Ba-atom((x - 1, y - 1, z-offset), "back-bl")
Ba-atom((x + 1, y - 1, z-offset), "back-br")
Ba-atom((x - 1, y + 1, z-offset), "back-tl")
Ba-atom((x + 1, y + 1, z-offset), "back-tr")
O-atom((x, y, z-offset), "back")
Ti-O-bond((x, y, z-offset), "back")
// --- Middle Plane (z = z-offset/2) ---
if ti-y >= 0 {
Ti-O-bond((x, y + 1, z-offset/2), "top")
}
if ti-y <= 0 {
Ti-O-bond((x, y - 1, z-offset/2), "bottom")
}
Ti-O-bond((x - 1, y, z-offset/2), "left")
Ti-O-bond((x + 1, y, z-offset/2), "right")
O-atom((x, y + 1, z-offset/2), "top")
O-atom((x, y - 1, z-offset/2), "bottom")
O-atom((x - 1, y, z-offset/2), "left")
O-atom((x + 1, y, z-offset/2), "right")
Ti-atom((x, y + ti-y, z-offset/2))
// --- Front Plane (z = 0) ---
Ti-O-bond((x, y, 0), "front")
Ba-atom((x - 1, y - 1, 0), "front-bl")
Ba-atom((x + 1, y - 1, 0), "front-br")
Ba-atom((x - 1, y + 1, 0), "front-tl")
Ba-atom((x + 1, y + 1, 0), "front-tr")
O-atom((x, y, 0), "front")
}
// Draw three unit cells with different Ti displacements
scale(0.64)
set-origin("potential-curve.mid")
draw-unit-cell(-4.5, 2, -0.2, "cell1")
draw-unit-cell(-0.5, 2, 0, "cell2")
draw-unit-cell(3.5, 2, 0.2, "cell3")
})