Showing posts with label i_grok_qe. Show all posts
Showing posts with label i_grok_qe. Show all posts

Monday, May 6, 2013

Ubuntu remote update

http://blog.ryanrampersad.com/2010/07/update-ubuntu-via-terminal/

no magic, just a tiny reminder if you need to update an ubuntu server remotely:

sudo apt-get update
sudo apt-get upgrade

Thursday, April 18, 2013

Phonon and Irreps in Quantum Espresso

http://math.stackexchange.com/a/38963

The above link contains a simple, understandable answer to the frustrating question: What are irreducible representations ?

If you do Quantum Espresso Phonon calculations with ph.x you have heard about them as irreps.

What the code does is that, once you define which phonon wavenumber (q) you want the dynamical matrix to be calculated for, the code looks for the small group of q.

Small group of q is found by selecting , among the point group symmetries of the crystal, the operations that leave the vector q unchanged, or carries it to -q+G , where G is a reciprocal space vector.

And once you know the small group of q, you can write this group in terms of its irreducible representations.

Then the code carries on the understand, for each phonon mode, which irreducible representation they belong to:

The outcome looks like this:

There are   3 irreducible representations

Representation     1      2 modes -  To be done
Representation     2      2 modes -  To be done
Representation     3      2 modes -  To be done

I like the explanation by Arturo Magidin in the mentioned link so much that I decided to mirror it here so that perhaps it will be better protected from the perils of online existence :)
All credits go to original author

!---------------------------------------
A representation of the group G means a homomorphism from G into the group of automorphisms of a vector space V. Essentially, you are trying to interpret each element of G as an invertible linear transformation VV, in order to try to understand the group G by how it "acts on V."

If you have an action ρ1 of G on a vector space W (that is, one representation), and you have some other action ρ2 of G on another vector space Z (another representation), then you can use these two actions to construct an action of G on the vector space WZ: just let G act on the first coordinate using the old action on W, and let it act on the second coordinate using the old action on Z.

The point to observe, however, is that the action of G on WZ defined this way does not give you any new insights into the structure of G: anything you can glean about G from this action, you can learn about G by considering the original actions ρ1 and ρ2. So this new action does not give us anything new.

Conversely, suppose you have one representation ρ, with G acting on V, and that there are proper subspaces W and Z of V that satisfy the following properties:

  1. V=WZ; and
  2. The action of every gG on V maps W to itself; and
  3. The action of every gG on V maps Z to itself.
Then you can look at the restriction of the action of G on W to get a representation, and the restriction on Z to get another representation; and these two representations will give you all the information from the original representation, the same way we had before. The advantage being that since W and Z are proper subspaces of V, they have smaller dimension and, presumably, it's easier to understand a subgroup of linear automorphisms for them than for V.

So the moral is that we want to find representations that cannot be "broken up" into smaller ones, because there's no point in trying to understand ones that do break up, we can focus our attention on those that don't, because all the other representations can be built up in terms of the ones that cannot be broken up.

The irreducible representations are precisely the ones that cannot be broken up into smaller pieces. There is a theorem that says that if you have a representation ρ of G acting on V, and W is a subspace of V such that for all gG, the image of W under the action of g is W itself, then you can find a subspace Z of V such that V=WZ and every gG maps Z to itself (that is, in order to break up ρ into two smaller pieces, it is enough to find a single proper piece on which ρ acts; then you can find a complement for it). With this in mind, we say:

Let ρ:GAut(V) be a representation of G. We say that ρ is irreducible if and only if V is not the zero vector space, and the only subspaces of V that are mapped to themselves under the action of every gG are {0} and V itself.
An irreducible representation of SO(3) will be a representation of SO(3) that is irreducible. SO(3) acts naturally on the vector space R3: it consists of all automorphisms of R3 that respect the inner product, so this is itself a representation of SO(3) (which is irreducible, because no proper subspace of R3 is sent to itself by all elements of SO(3)). 
!---------------------------------------

Tuesday, February 5, 2013

svn list conflict files

I ran an svn merge between my branch and svn trunk:

cd ~/mylocal/branch

svn merge -r1234:5678 svn+ssh://server/trunk .

There were alotof changes in the main trunk to be merged into my branch and several conflicts which i simply postponed. (p)

Then, when I needed to resolve te conflicts at a later time, I wanted to see only the name of the files with conflicts. The commandline one liner below grepped it:

svn status | grep -P '^(?=.{0,6}C)'

Wednesday, November 7, 2012

standard devition with awk

Basics. Just to write it down once and for all
 
awk '{sum+=$1; sum2+=$1*$1} END {print sqrt(sum2/NR - (sum/NR)**2)}' file.dat
 
and when the above overflows due to big numbers
 
awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' file.dat
 
heart commandlinefu for quick references when the iq drops at the end of the day.


Tuesday, October 30, 2012

svn diff filename only & svn diff side by side

Subversion svn has its own built in diff but its capabilities are not as wide as GNU diff. But there is a work around for everything.
For example, if you want to GNU diff and show only file names not details, diff -q would do. Same thing in svn diff would be like this:

svn diff --diff-cmd "diff" -x "-q" . | grep Index | cut -d " " -f 2

lets break it down:

svn diff is the command (duh)
--diff-cmd means we want to use an external program to display the differences, which in our case is
"diff"
-x this external program is going to get some options (--extensions= -x) which in your case is
"-q"

The rest is self explanatory i guess but let me continue.
For every file that differs, the output of the svn diff --diff-cmd "diff" -x "-q" . will be
File <filename> <revison> and <filename> <revison2> differ
Index: <filename>
that is why we grep Index
and then we cut (cut) this string using space (" ") as delimeter (-d) and just choose the second field (-f 2), so we dont get the Index: part

and Ta-Taaaa!

svn diff --diff-cmd "diff" -x "-q" . | grep Index | cut -d " " -f 2

Now following the same idea, we will write how to svn diff side-by-side

svn diff --diff-cmd "diff" -x "-y" 

And if you are only interested in the lines that differ

svn diff --diff-cmd "diff" -x "-y --supress-common-lines"

Now you know how to extend this to any diff option.. go play child.

Tuesday, October 2, 2012

Xcrysden attributes

XCRYSDEN, the favorite visualization tool of all Quantum Espresso users..
OK maybe not that much favorite but you all use it from time to time. It is very handy that it reads and interprets QE input and outputs automagically.
========
It really requires a sort of magic to keep up with the ouput format of QE, that is why it is generally wiser to draw your structures from input files.

You already know this but let me rewrite the command line options regarding pw.x input and outputs :

xcrysden --pwi your_pw_input.in
xcrysden --pwo your_pw_output.in
========
Attributes: Colors and R a d i u s

one thing that might come handy to you all is to use attributes file for the color and radius of elements, so that you wont have to change it manually each time you open a new structure.

an attribute file looks like the following:

cat > attributes.dat << EOF
ELEMENTCOLOR
atomic_no_1 1_red 1_green 1_blue
....
atomic_no_n  n_red n_green n_blue
ELEMENTRADIUS
atomic_no_1 1_radius
....
atomic_no_n n_radius
EOF

atomic no refers to atomic numbers of the atoms you want to change the attributes of.
red, green, blue is to define the new color in rgb setting, scaled within 0-1
radius is the new radius you want to have, obviously.

For making all hydrogens a bit bigger and in  cute pink :)

cat > attributes_file << EOF
ELEMENTCOLOR
1  0.88 0.00 0.42
ELEMENTRADIUS
1 0.9EOF

and then run xcrysden like this

xcrysden -a attributes_file --pwi your_pw_input.in
============
Other attributes

So you can use the above attributes file to change color and radius for each calculation. But that wouldnt be very practical if this was the setting you always want to keep. Also, using an attribute file you can only change the color and the radius. For other properties we have to edit the following file:

~/.xcrysden/custom_definitions 

This is where bunch of settings can be redefined, from printing settings to fonts.
Lets take a quick look at some definitions that can be rewritten in this file and that I actually needed to change on some occasions:
  • set select(dist_precision/angl_precision) n  Precision that the distance/angle etc measurer reports
  • set atmRad(atomic_number) radius Atomic dispay radius
  • set atmCol(atomic_number) {red green blue} color, like in attributes file above
  • set myParam(BALLF) ball_factor Ball-Factor
  • set myParam(RODF) rod_factor Rod-Factor
  • set myParam(FRAMELINEWIDTH) n Crystal cell frame width
  • set myParam(FRAMECOL) {red green blue} Color of the crystal frame
  • set myParam(BACKGROUND) {red green blue} Background color, currently {0 0 0}, I always do white {1 1 1} for papers
  • set myParam(ATOMIC_LABEL_FONT) -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 This is the current font of atomic labels, in X11 XLFD format. Where the font family, size of the font, italic or upright, bold or medium, spacing etc. can be defined. Play around.
For more, you can take a look at the ~/.xcrysden/custom_definitions file yourself and experiment.

Monday, October 1, 2012

input for plotrho.x

Yet another trivial Quantum Espresso post processing tool,
that probably does not require any documentation when you run it interactively
but it is useful to have the namelist written somewhere, to be able to write scripts.

So here is the input file for plotrho.x

cat > plotrho_input.in <<EOF
filename_in.dat
filename_out.ps
y or n
min_rho max_rho n_levels
EOF

filename_in.dat :
This is the file that holds the charge density information.  It is generally generated by a previous program (pw.x  + pp.x)
From this file, the plotrho.x reads the origin of the cell ( r0=(0,0,0) ), atomic positions, real space grid the density is written to filename.in, and of course the density to be plotted.

filename_out.ps :
the charge density plot that would be produced.

( y | n ) :
Answer to the question "Do you want to use logarithmic scale ? "

min_rho max_rho:
Minimum and maximum of the scale of the contour plot.

n_levels
how many levels this charge density range will be divided to for the contour plot.

Remember, whenever you are in doubt, run interactively for the code to prompt you what is what.
have fun!


Sunday, September 23, 2012

Quantum Espresso GIPAW: Macroscopic shape matters

The ones of you who use QE-GIPAW for molecules in gas phases only would not know this but when you are dealing with solids be careful of this keyword:

use_nmr_macroscopic_shape

'Coz in solids, macroscopic shape really does matter. What do I mean?

When calculating chemical shifts (calculation='nmr') what we actually do is to assume that there is a tiny perturbative magnetic field affecting the electronic structure. Electrons respond to this field by inducing a current in the sample, and as every damn current, this induced current too, induces a magnetic field in the sample. We are only interested in the induced magnetic field at the nuclei positions.

Ok I have really over simplified the whole thing :) but lets continue. When you have a molecule, there is not much more to it, calculate the current, calculate the induced field and you are done. However a finite solid sample can sustain surface currents and your infinitely periodic unit cell does not know anything about it.

Depending on the strength of this surface current, one has to consider its affect on the chemical shifts. As it has everything to do with the surface ( therefore macroscopic shape of the sample ) you need to tell the code what this shape is. Say, if you are comparing to an experiment, check the shape they give in the article: slab? cylindrical? spherical? and supply this info using nmr_macroscopic_shape array.

here is for a spherical sample (default)

use_nmr_macroscopic_shape=.true.
nmr_macroscopic_shape(1:1)=2/3
nmr_macroscopic_shape(2:2)=2/3
nmr_macroscopic_shape(3:3)=2/3

And the code does add a shape correction proportional to the macroscopic susceptibility (chi) with

4*pi* nmr_macroscopic_shape(:,:) *chi_bare(:,:)

But where is this 2/3 coming from? why not 1/3, like in the normal depolarization coefficients of a sphere (n_depol)?

Well, 'coz the real equation is

B_total = B_induced - 4*pi*(1 − n_depol)*chi

but the code expects _you_ to do the (1-n) operation in your mind, duck face :)

So if you have a cylinder along z:

nmr_macroscopic_shape(1:1)=1/2
nmr_macroscopic_shape(2:2)=1/2
nmr_macroscopic_shape(3:3)=1


And a slab along z: 

nmr_macroscopic_shape(1:1)=1 
nmr_macroscopic_shape(2:2)=1
nmr_macroscopic_shape(3:3)=0


(For more theoretically inclined, another way of looking at this is shape contribution is solving for the magnetic field in the sample with boundary conditions that are set by the shape of the sample, unlike G=0 term vanishing in electric fields, here solve separately for infinite sample and add macroscopic susceptibility contribution. If there is any demand I will write down the equations otherwise go to your favorite Electromagnetism textbook, like Jackson chapter 5 )



Different Isotopes with Quantum Espresso GIPAW

I get this question time to time,
how does a nuclear magnetic resonance property like chemical shifts are calculated by Quantum Espresso? How do you simulate the nuclear spin?

The thing is, for the chemical shifts (calculation='NMR') , the level of assumptions we make in QE-GIPAW leave us totally free from simulating the nuclear spin. What we look at is how the electronic structure induces a magnetic field at nuclei position.

So, within the limits of the theory, everything depends on the surrounding electronic structure. The code does not have to know if it is X113 or X112 isotope..

Lets say you are looking at the chemical shifts of boron, B10 or B11 does not make any difference to the code, at least not for the chemical shifts, sigma(iso)

But of course if you have a nuclei with spin > 1/2; you need to know which isotope you are dealing with to continue with nuclear electric quadrupole interactions, namely the Cq's and eta's as commonly denoted. Back to Boron, B10 has double the moment of B11 but 1/5th of natural abundance. So just remember to input these parameters in your electric field gradient (EFG) calculations when dealing with isotopes with with spin > 1/2 through keywords q_efg(i) for element i.

Damn simple :)

ps: i check webelements for q_efg's, under NMR properties. Here is Boron: http://www.webelements.com/boron/nmr.html

pps: Natural abundance matters. Remember to check that and average as needed. EFG calculations are very cheap anyways.

ppps: Unit of electric quadrupole moment in quantum espresso gipaw routine is [ electron*10e-30 meter ^2 ] not [electron*milibarn]. The conversion is straighforward: Find the milibarn value, divide by 10, input in Quantum Espresso q_efg. Come on I cannot help more than this :)



Wednesday, September 12, 2012

Pseudopotential Theory Review

There is a rather recent review of pseudopotential theory for electronic structure calculations. It is mostly from a chemist's point of view and I couldn't take a good look at it myself yet,
so I am writing it here to remind it to my future self.

Yes, I am talking to you, close the 9gag app right now and read:

http://onlinelibrary.wiley.com/doi/10.1002/cphc.201100387/pdf

Tuesday, July 10, 2012

XSF for Xcrysden

XSF format explained below.

As I recently write my own files to compare results of different pseudos as an animation. Cheers me up.

http://www.xcrysden.org/doc/XSF.html#__toc__1

Saturday, July 7, 2012

Pseudopotentials for GIPAW

The following links are very useful if you are using Quantum Espresso for GIPAW calculations (NMR, EPR etc.)

If any of the contributors is reading this: Thank you! :)

And more generally for your pseudopotential needs:

Monday, June 4, 2012

Compile QE using parallel make

It takes too long to compile espresso for the first time. Especially if you are dealing with several versions at the same time, on different machines and trying out different MPI or scalapack options etc, forget about doing any actual physics that day, all goes to espresso installation and compilation.

I like to use parallel gnu make to get things quite faster

> make -j 15 pw

But the Makefile of espresso is buggy, in the sense that the dependencies are not listed properly, at the moment thanks to the generate_vdW_kernel_table.f90 Normally I would just list it on the dependencies and be done with it, but this is Quantum Espresso, you don't know whose hands are gonna be in the code in a month and it will be broken the same.. (I know coz I have done similar stuff when I started developing with it:)

So I now do the dirty way around
>make -j 15 -k pw; make -j 15 pw

-j or --jobs to run parallel, default is 1, -k for "keep going" even if you have encountered errors in some commands. 15 is the number of jobs I have asked for. There is a dynamic load determining option, -l . If you need more from your gnu make, well, google is your friend  :) 

hope this helps.

Tuesday, May 29, 2012

input for plotband.x

It is fairly trivial but might help some beginner some day..

Input format for Quantum Espresso post-processing executable plotband.x is

name_of_file_produced_by_bands.dat
name_of_grace_output.xmgr
name_of_ps_output.ps
e_fermi_value
delta_energy, reference_energy

You can run it interactively any time you forget what is what, so that the code prompts you the question, like "name of the bands file pls " etc
but if you wanna have it in your script, you can use the above definitions.

hope this helps.