@@ -279,13 +279,25 @@ Examples of covectors are forces.
279
279
Reciprocal vectors are a special case: they are covectors, but conventionally have an
280
280
additional factor of 2π in their definition, so they transform rather with 2π times the
281
281
inverse lattice transpose: q_cart = 2π lattice' \ q_red = recip_lattice * q_red.
282
+
283
+ For each of the function there is a one-argument version (returning a function to do the
284
+ transformation) and a two-argument version applying the transformation to a passed vector.
282
285
=#
283
- vector_red_to_cart (model:: Model , rred) = model. lattice * rred
284
- vector_cart_to_red (model:: Model , rcart) = model. inv_lattice * rcart
285
- covector_red_to_cart (model:: Model , fred) = model. inv_lattice' * fred
286
- covector_cart_to_red (model:: Model , fcart) = model. lattice' * fcart
287
- recip_vector_red_to_cart (model:: Model , qred) = model. recip_lattice * qred
288
- recip_vector_cart_to_red (model:: Model , qcart) = model. inv_recip_lattice * qcart
286
+ @inline _gen_matmul (mat) = vec -> mat * vec
287
+
288
+ vector_red_to_cart (model:: Model ) = _gen_matmul (model. lattice)
289
+ vector_cart_to_red (model:: Model ) = _gen_matmul (model. inv_lattice)
290
+ covector_red_to_cart (model:: Model ) = _gen_matmul (model. inv_lattice' )
291
+ covector_cart_to_red (model:: Model ) = _gen_matmul (model. lattice' )
292
+ recip_vector_red_to_cart (model:: Model ) = _gen_matmul (model. recip_lattice)
293
+ recip_vector_cart_to_red (model:: Model ) = _gen_matmul (model. inv_recip_lattice)
294
+
295
+ vector_red_to_cart (model:: Model , vec) = vector_red_to_cart (model)(vec)
296
+ vector_cart_to_red (model:: Model , vec) = vector_cart_to_red (model)(vec)
297
+ covector_red_to_cart (model:: Model , vec) = covector_red_to_cart (model)(vec)
298
+ covector_cart_to_red (model:: Model , vec) = covector_cart_to_red (model)(vec)
299
+ recip_vector_red_to_cart (model:: Model , vec) = recip_vector_red_to_cart (model)(vec)
300
+ recip_vector_cart_to_red (model:: Model , vec) = recip_vector_cart_to_red (model)(vec)
289
301
290
302
#=
291
303
Transformations on vectors and covectors are matrices and comatrices.
@@ -300,7 +312,14 @@ s_cart = L s_red = L A_red r_red = L A_red L⁻¹ r_cart, thus A_cart = L A_red
300
312
Examples of matrices are the symmetries in real space (W)
301
313
Examples of comatrices are the symmetries in reciprocal space (S)
302
314
=#
303
- matrix_red_to_cart (model:: Model , Ared) = model. lattice * Ared * model. inv_lattice
304
- matrix_cart_to_red (model:: Model , Acart) = model. inv_lattice * Acart * model. lattice
305
- comatrix_red_to_cart (model:: Model , Bred) = model. inv_lattice' * Bred * model. lattice'
306
- comatrix_cart_to_red (model:: Model , Bcart) = model. lattice' * Bcart * model. inv_lattice'
315
+ @inline _gen_matmatmul (M, Minv) = mat -> M * mat * Minv
316
+
317
+ matrix_red_to_cart (model:: Model ) = _gen_matmatmul (model. lattice, model. inv_lattice)
318
+ matrix_cart_to_red (model:: Model ) = _gen_matmatmul (model. inv_lattice, model. lattice)
319
+ comatrix_red_to_cart (model:: Model ) = _gen_matmatmul (model. inv_lattice' , model. lattice' )
320
+ comatrix_cart_to_red (model:: Model ) = _gen_matmatmul (model. lattice' , model. inv_lattice' )
321
+
322
+ matrix_red_to_cart (model:: Model , Ared) = matrix_red_to_cart (model)(Ared)
323
+ matrix_cart_to_red (model:: Model , Acart) = matrix_cart_to_red (model)(Acart)
324
+ comatrix_red_to_cart (model:: Model , Bred) = comatrix_red_to_cart (model)(Bred)
325
+ comatrix_cart_to_red (model:: Model , Bcart) = comatrix_cart_to_red (model)(Bcart)
0 commit comments