Skip to content

Instantly share code, notes, and snippets.

@utf
Created August 20, 2021 15:14
Show Gist options
  • Save utf/1d0f4c2d2c716af559f25e390b6b2b99 to your computer and use it in GitHub Desktop.
Save utf/1d0f4c2d2c716af559f25e390b6b2b99 to your computer and use it in GitHub Desktop.
#! /usr/bin/awk -f
#
# Name: Extract elastic constant tensor
# Author: Alex Ganose
# Version: 1.0
# Date: 20/08/21
# Usage: elastic [OUTCAR]
/TOTAL ELASTIC MODULI/ {
l = NR
}
(NR == l + 3) {
C1111 = $2 / 10
C1122 = $3 / 10
C1133 = $4 / 10
C1112 = $5 / 10
C1123 = $6 / 10
C1131 = $7 / 10
}
(NR == l + 4) {
C2211 = $2 / 10
C2222 = $3 / 10
C2233 = $4 / 10
C2212 = $5 / 10
C2223 = $6 / 10
C2231 = $7 / 10
}
(NR == l + 5) {
C3311 = $2 / 10
C3322 = $3 / 10
C3333 = $4 / 10
C3312 = $5 / 10
C3323 = $6 / 10
C3331 = $7 / 10
}
(NR == l + 6) {
C1211 = $2 / 10
C1222 = $3 / 10
C1233 = $4 / 10
C1212 = $5 / 10
C1223 = $6 / 10
C1231 = $7 / 10
}
(NR == l + 7) {
C2311 = $2 / 10
C2322 = $3 / 10
C2333 = $4 / 10
C2312 = $5 / 10
C2323 = $6 / 10
C2331 = $7 / 10
}
(NR == l + 8) {
C3111 = $2 / 10
C3122 = $3 / 10
C3133 = $4 / 10
C3112 = $5 / 10
C3123 = $6 / 10
C3131 = $7 / 10
}
END {
if (l > 1) {
print "elastic_constant:"
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C1111, C1122, C1133, C1123, C1131, C1112
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C2211, C2222, C2233, C2223, C2231, C2212
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C3311, C3322, C3333, C3323, C3331, C3312
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C2311, C2322, C2333, C2323, C2331, C2312
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C3111, C3122, C3133, C3123, C3131, C3112
printf " - [ %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f ]\n", C1211, C1222, C1233, C1223, C1231, C1212
} else {
print "ERROR: No elastic tensor found"
}
}
@utf
Copy link
Author

utf commented Feb 16, 2024

Hi @deepakgit2, no there have been no updates in the AMSET code. The user is responsible for inserting the elastic constants in the correct format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment