Get mag.sh

From Wiki
Revision as of 10:33, 31 August 2017 by 10.0.7.15 (talk) (New page: #!/usr/bin/env bash # Written by Qiang # To get the Magnetization of specific atoms # To use it: ###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Method A : If yo...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. !/usr/bin/env bash
  2. Written by Qiang
  3. To get the Magnetization of specific atoms
  4. To use it:
      1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. Method A : If you want to get the information of the 14th atom
                      1. bash get_mag.sh 14
  6. Method B : If you want to get the information of atoms: 2 4 6 8 10
                      1. for i in 2 4 6 8 10 ; do bash get_mag.sh $i ; done
      1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1. Get the line number of the last magnetization (x)

Nline=$(grep -nr 'magnetization (x)' OUTCAR | tail -n 1 | awk '{print $1}' |sed 's/://g')

    1. Get the total atoms number

Natom=$(sed -n 7p CONTCAR |tr ' ' '\n' | sed '/^$/d' | paste -sd+ | bc)

    1. Start line of Magnetization part

Nstart=$(($Nline+4))

    1. End line of Magnetization part

Nend=$(($Nstart+$Natom-1))

    1. Extract the Magnetization part

if [ ! -e mag-temp ]; then sed -n "$Nstart, $Nend p" OUTCAR > mag-temp fi

    1. Read and print the specific atom's magnetization

sed -n "$1 p" mag-temp

    1. Remove the temp file: mag-temp contains all atoms' magnetization information
  1. rm mag-temp -f