Get mag.sh: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
Qli (talk | contribs)
No edit summary
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
go back to [[Main Page]], [[Computational Resources]], [[Scripts]], [[Scripts for VASP]] or [[VASP]]
go back to [[Main Page]], [[Computational Resources]], [[Scripts]], [[Scripts for VASP]] or [[VASP]]
  [[Image:Get mag.tgz]]


This script will do the following:
This script will do the following:
Line 9: Line 11:
3) Prints the magnetization of the atoms you want to check.  
3) Prints the magnetization of the atoms you want to check.  


Note1:  
'''Note 1: '''


To get the magnetization information, we need set:
To get the magnetization information, we need set:


ISPIN = 2
MAGMOM = xxx (It depends on your system)
LORBIT = 11


Note2 :  
ISPIN = 2
 
MAGMOM = xxx (It depends on your system)
 
LORBIT = 11
 
 
'''Note 2: '''


The total magnetization in OUTCAR is less than the value from OSZICAR. This is because:
The total magnetization in OUTCAR is less than the value from OSZICAR. This is because:
Line 34: Line 40:




To use this script:
'''To use this script:'''


1) Get one atom's magnetization: for example, atom 15:  
1) Get one atom's magnetization: for example, atom 15:  


get_mag.sh 15   
  get_mag.sh 15   




2) Get many atoms' magnetization, for example, atoms: 1 3 5 7 9  
2) Get many atoms' magnetization, for example, atoms: 1 3 5 7 9  


for i in 1 3 5 7 9  ; do get_mag.sh $i ; done  
    for i in 1 3 5 7 9  ; do get_mag.sh $i ; done  
 


3) You can also save the atom list in a file (atom-list): and do the following:  
3) You can also save the atom list in a file (atom-list): and do the following:  


for i in $(cat atom-list) ; do get_mag.sh $i ; done  
  for i in $(cat atom-list) ; do get_mag.sh $i ; done  


Enjoy!
Enjoy!




----


== CODE ==
#!/usr/bin/env bash  
 
# Written by Qiang  
#!/usr/bin/env bash  
# To get the Magnetization of specific atoms
# Written by Qiang  
# To use it:  
# To get the Magnetization of specific atoms
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# To use it:  
# Method A : If you want to get the information of the 14th atom  
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
###########  bash get_mag.sh 14
# Method A : If you want to get the information of the 14th atom  
# Method B : If you want to get the information of atoms: 2 4 6 8 10
###########  bash get_mag.sh 14
###########  for i in 2 4 6 8 10 ; do bash get_mag.sh $i ; done  
# Method B : If you want to get the information of atoms: 2 4 6 8 10
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
###########  for i in 2 4 6 8 10 ; do bash get_mag.sh $i ; done  
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
## Get the line number of the last magnetization (x)
 
Nline=$(grep -nr 'magnetization (x)'  OUTCAR  | tail -n 1 | awk '{print $1}' |sed  's/://g')
## Get the line number of the last magnetization (x)
Nline=$(grep -nr 'magnetization (x)'  OUTCAR  | tail -n 1 | awk '{print $1}' |sed  's/://g')
## Get  the total atoms number  
 
Natom=$(sed -n 7p CONTCAR  |tr ' ' '\n'  |  sed '/^$/d' | paste -sd+ | bc)
## Get  the total atoms number  
Natom=$(sed -n 7p CONTCAR  |tr ' ' '\n'  |  sed '/^$/d' | paste -sd+ | bc)
## Start line of Magnetization part  
 
Nstart=$(($Nline+4))
## Start line of Magnetization part  
Nstart=$(($Nline+4))
## End line of Magnetization part  
 
Nend=$(($Nstart+$Natom-1))
## End line of Magnetization part  
Nend=$(($Nstart+$Natom-1))
## Extract the Magnetization part
 
if [ ! -e mag-temp ];   
## Extract the Magnetization part
then  
if [ ! -e mag-temp ];   
sed -n "$Nstart, $Nend p" OUTCAR > mag-temp
then  
fi   
sed -n "$Nstart, $Nend p" OUTCAR > mag-temp
fi   
## Read and print the specific atom's magnetization  
 
sed -n "$1 p" mag-temp
## Read and print the specific atom's magnetization  
sed -n "$1 p" mag-temp
## Remove the temp file: mag-temp contains all atoms' magnetization information  
 
# rm mag-temp -f
## Remove the temp file: mag-temp contains all atoms' magnetization information  
# rm mag-temp -f

Latest revision as of 11:08, 31 August 2017

go back to Main Page, Computational Resources, Scripts, Scripts for VASP or VASP

  File:Get mag.tgz 

This script will do the following:

1) Reads CONTCAR and calculate the total atom numbers;

2) Extracts the magnetization information from the OUTCAR to a file named mag-temp ;

3) Prints the magnetization of the atoms you want to check.

Note 1:

To get the magnetization information, we need set:


ISPIN = 2 
MAGMOM = xxx (It depends on your system)
LORBIT = 11 


Note 2:

The total magnetization in OUTCAR is less than the value from OSZICAR. This is because:

The difference in the values roots in the fact that, when you project the magnetization on the atoms,

you use a default value (RWIGS) to define the radius of each atom.

For this reason, even if you compute the magnetization for all the atoms,

the sum of their "volume" does not fill up the total volume of the unit cell,

and so the sum of the projections of the magnetization on each atom is different from the overall magnetization, written in the OSZICAR.

PS: I copied the explanations above from http://cms.mpi.univie.ac.at/vasp-forum/viewtopic.php?t=15642


To use this script:

1) Get one atom's magnetization: for example, atom 15:

  get_mag.sh 15  


2) Get many atoms' magnetization, for example, atoms: 1 3 5 7 9

   for i in 1 3 5 7 9  ; do get_mag.sh $i ; done 


3) You can also save the atom list in a file (atom-list): and do the following:

  for i in $(cat atom-list) ; do get_mag.sh $i ; done 

Enjoy!



#!/usr/bin/env bash 
# Written by Qiang 
# To get the Magnetization of specific atoms
# To use it: 
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Method A : If you want to get the information of the 14th atom 
###########   bash get_mag.sh 14
# Method B : If you want to get the information of atoms: 2 4 6 8 10
###########   for i in 2 4 6 8 10 ; do bash get_mag.sh $i ; done 
###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

## Get the line number of the last magnetization (x)
Nline=$(grep -nr 'magnetization (x)'  OUTCAR  | tail -n 1 | awk '{print $1}' |sed  's/://g')

## Get  the total atoms number 
Natom=$(sed -n 7p CONTCAR  |tr ' ' '\n'  |  sed '/^$/d' | paste -sd+ | bc)

## Start line of Magnetization part 
Nstart=$(($Nline+4))

## End line of Magnetization part 
Nend=$(($Nstart+$Natom-1))

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

## Read and print the specific atom's magnetization 
sed -n "$1 p" mag-temp

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