Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pmitev committed Sep 25, 2020
0 parents commit b615ca7
Show file tree
Hide file tree
Showing 167 changed files with 226,981 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gawk
vim
nano
mc
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ci
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
23 changes: 23 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: doc/requirements.txt
13 changes: 13 additions & 0 deletions 01.Simple_examples/coins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gold 1 1986 USA American Eagle
gold 1 1908 Austria-Hungary Franz Josef 100 Korona
silver 10 1981 USA ingot
gold 1 1984 Switzerland ingot
gold 1 1979 RSA Krugerrand
gold 0.5 1981 RSA Krugerrand
gold 0.1 1986 PRC Panda
silver 1 1986 USA Liberty dollar
gold 0.25 1986 USA Liberty 5-dollar piece
silver 0.5 1986 USA Liberty 50-cent piece
silver 1 1987 USA Constitution dollar
gold 0.25 1987 USA Constitution 5-dollar piece
gold 1 1988 Canada Maple Leaf
8 changes: 8 additions & 0 deletions 01.Simple_examples/count.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/awk -f
{
country[$4]++
}

END {
for (i in country) print "Country: " i," count: ", country[i]
}
3 changes: 3 additions & 0 deletions 01.Simple_examples/data
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 2 3
4 5 6
7 8 9 10 text
7 changes: 7 additions & 0 deletions 02.Gaussian/extract_data.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/awk -f

BEGIN { AU2eV= 27.211383 }

/Distance matrix/ {getline; getline; getline; getline; getline; getline; rOH= $5}

/Counterpoise: corrected energy/ { printf "%.12f %.6f\n", rOH, $5*AU2eV }
92,171 changes: 92,171 additions & 0 deletions 02.Gaussian/gaussian.out

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions 03.Dipole_moment/dipole_moment.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/awk -f
# x,y,z in Angstroms
NR > 2 {
mx= mx + $2*$5; my= my + $3*$5; mz= mz + $4*$5;
}

END {
norm=sqrt(mx**2+my**2+mz**2);
# Convert to Debye
toD= 4.80320425;
mx= mx*toD; my= my*toD; mz= mz*toD;
norm= norm*toD;
printf("Dipole Moment\t x\t\t y\t\t z\t\t| D.Moment |\n");
printf(" [ Debye ] \t%f\t%f\t%f\t%f\n", mx, my, mz, norm);
}
9 changes: 9 additions & 0 deletions 03.Dipole_moment/waterX.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
7
Wannier centres, written by Wannier90 on 6Aug2013 at 14:23:10
X 6.50000026 6.18706578 6.50000000 -2
X 6.50000000 6.71337672 6.50000002 -2
X 6.50000008 6.95339960 6.49999998 -2
X 6.49999971 6.54636884 6.50000000 -2
H 6.50000000 7.09480000 7.26880000 1
H 6.50000000 7.09480000 5.73120000 1
O 6.50000000 6.50000000 6.50000000 6
5 changes: 5 additions & 0 deletions 04.Join_data/1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Daniel 10
Anders 7
Sven 56
Ali 17
Peter 6
3 changes: 3 additions & 0 deletions 04.Join_data/2.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Peter Monday
Sven Sunday
David Tuesday
10 changes: 10 additions & 0 deletions 04.Join_data/join.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/awk -f

{
names[$1]= 1;
data[$1,ARGIND]= $2
}

END{
for (i in names) print i"\t\t"data[i,1]"\t\t"data[i,2]
}
Binary file added 05.Gauss-smearing/Gauss-smearing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions 05.Gauss-smearing/freq.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Anharm harm
2858.351 3173.516
2797.693 3131.408
2682.453 3019.173
2710.734 3056.025
2989.402 3273.493
2558.539 2919.306
2781.281 3111.231
2707.999 3052.427
2575.868 2934.403
2784.882 3111.663
2977.694 3266.289
2652.853 2993.294
2868.582 3163.679
3076.485 3334.419
2883.267 3188.332
3137.228 3389.384
3425.697 3615.290
3094.083 3356.917
33 changes: 33 additions & 0 deletions 05.Gauss-smearing/gauss-smear-data.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/awk -f
BEGIN{
FWHM=30; # Default smearing if none is provided on the command line
FWHM= FWHM/2.35482
# trick to read parameters from the command line
if (ARGC==3) FWHM=ARGV[2]; ARGC=2;
}

!/#/ {
f++;
if (f==1) {fmin=$1; fmax=$1}

freq[f]=$1;
if (fmin > $1) fmin=$1;
if (fmax < $1) fmax=$1;
nfreq=f;
}

END{
print "# freq intensity | nfreq: "nfreq" fmin: "fmin" fmax: "fmax
for (i=int(fmin -5*FWHM); i<=int(fmax +5*FWHM);i++){
for (f=1;f<=nfreq;f++){
data[i]= data[i] + gauss(freq[f],i,FWHM);
}
print i,data[i]
}
}

function gauss(x0,x,c){
area=1;
if ((x-x0)**2 < 10000) { return area*exp(-(((x-x0))**2)/(2.*c**2))}
else {return 0.0}
}
17 changes: 17 additions & 0 deletions 05.Gauss-smearing/ps-plot-v01.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/gnuplot

set term pngcairo size 800, 400 enhanced
set out "Gauss-smearing.png"

set border

set key top left
set title "Gaussian smearing with FWHM 10 and 30"
set xlabel "Frequency"
set ylabel "Intensity"

plot "< ./gauss-smear-data.awk freq.dat 30" u ($1 ):($2) w l t "Gauss smearing 30" lw 2,\
"< ./gauss-smear-data.awk freq.dat 10" u ($1 ):($2) w l t "Gauss smearing 10" lw 2,\
"freq.dat" u ($1):(1) w impulses t "" lc rgb "blue"

!display Gauss-smearing.png
Binary file added 06.VASP_CHGCAR_diff/CHGCAR.ps
Binary file not shown.
21 changes: 21 additions & 0 deletions 06.VASP_CHGCAR_diff/VASP_CHGCAR_diff.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/awk -f
BEGIN{
cmd1= "bzcat "ARGV[1];
cmd2= "bzcat "ARGV[2];
cmd3= "bzcat "ARGV[3];

NF=1; while(NF>0){ cmd2 |& getline; } cmd2 |& getline;
NF=1; while(NF>0){ cmd3 |& getline; } cmd3 |& getline;
NF=1; while(NF>0){ cmd1 |& getline; print } cmd1 |& getline; print;

do {
cmd1 |& getline; split($0,d1)
cmd2 |& getline; split($0,d2)
cmd3 |& getline; split($0,d3)
for(i=1;i<=NF;i++) printf "%18.11e ", d1[i]-d2[i]-d3[i]
print""
} while ($1*1==$1)

}


117 changes: 117 additions & 0 deletions 06.VASP_CHGCAR_diff/plot-plane-v01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env python
# Author: Pavlin Mitev
# version 2015.10.22
import numpy as np
import os,sys,time
from math import sin, cos, degrees, radians
from ase import Atoms
from ase.calculators.vasp import VaspChargeDensity

import scipy.ndimage as ndimage

import matplotlib.pyplot as plt

#import scipy.interpolate as interpolate
#from scipy.interpolate import griddata

#======================================
atom1= 2 # atom in the center
atom2= 1 # atom from the plane
atom3= 0 # second atom in the plain

npx= 90 # number of point to sample the plane in x
npy= 90 # number of point to sample the plane in y

angle= radians(-144) # rotate the final plot around the central atom
#angle= radians(0)


start= time.time()
sys.stdout.write("Reading CHGCAR... "); sys.stdout.flush()
CHGCAR= VaspChargeDensity("CHGCAR")
end= time.time()
print "finished. {0}".format(end-start)


cell= CHGCAR.atoms[0].cell
nx,ny,nz= np.shape(CHGCAR.chg[0])
ncell= cell/np.array([nx,ny,nz])


# define plane =================================
p1= CHGCAR.atoms[0].get_scaled_positions()[atom1]
p2= CHGCAR.atoms[0].get_scaled_positions()[atom2]
p3= CHGCAR.atoms[0].get_scaled_positions()[atom3]

# get normal to the plane
v1= p2-p1;
v2= p3-p1;

v1n= np.dot(v1,cell); # v1 in Cartesian
v2n= np.dot(v2,cell); # v2 in Cartesian

v1n= v1n/np.linalg.norm(v1n) # v1 unit in Cartesian
v2n= v2n/np.linalg.norm(v2n) # v2 unit in Cartesian

vnorm= np.cross(v1n,v2n);
vnorm= vnorm/np.linalg.norm(vnorm)
#vnorm= np.dot(vnorm,cell) # vnorm in Cartesian

# Rotate the plane ==============================
axis = vnorm;
axis_skewed = [ [0, -axis[2], axis[1]], [ axis[2], 0, -axis[0] ] , [ -axis[1], axis[0], 0] ];
R = np.eye(3) + np.dot(sin(angle),axis_skewed) + (1-cos(angle))*np.dot(axis_skewed,axis_skewed);
v1n= np.dot(v1n,R)

v2n= np.cross(vnorm,v1n); # v2 is a vector in the same plane but perpendicular to v1n
v2n= v2n/np.linalg.norm(v2n)

v1n= np.dot(v1n,np.linalg.inv(cell)) # back to fractional
v2n= np.dot(v2n,np.linalg.inv(cell)) # back to fractional


grid= np.zeros((npx*npy,3))
ip= 0
for ix in np.linspace(-1.5,1.5,npx):
for iy in np.linspace(-1.5,1.5,npy):
grid[ip]= (v1n*ix + v2n*iy + p1)*[nx,ny,nz]
ip= ip + 1

grid_x, grid_y, grid_z= grid[:,0], grid[:,1], grid[:,2]
plane= ndimage.map_coordinates(CHGCAR.chg[0],[grid_x, grid_y, grid_z], mode="wrap")
px,py=np.mgrid[-1.5:1.5:npx+0j,-1.5:1.5:npy+0j]


plt.rcParams["figure.figsize"]=[ 8,8]

plt.plot([0],[0],'ko',ms=9 )

plt.plot( np.dot(np.dot(v1,cell),np.dot(v1n,cell)) , np.dot(np.dot(v1,cell),np.dot(v2n,cell)) , 'ko',ms=9 )
#plt.text( np.dot(np.dot(v1,cell),np.dot(v1n,cell)) , np.dot(np.dot(v1,cell),np.dot(v2n,cell))-0.1 , 'p1', alpha= 0.2)

plt.plot( np.dot(np.dot(v2,cell),np.dot(v1n,cell)) , np.dot(np.dot(v2,cell),np.dot(v2n,cell)) , 'ko',ms=9 )
#plt.text( np.dot(np.dot(v2,cell),np.dot(v1n,cell)) , np.dot(np.dot(v2,cell),np.dot(v2n,cell))-0.1 , 'p2', alpha= 0.2)

#CIM1= plt.imshow(plane.reshape(npx,npy).T, origin='lower', extent=(-1.5, 1.5, -1.5, 1.5), alpha=0.4, cmap='spectral')
CIM1= plt.imshow(plane.reshape(npx,npy).T, origin='lower', extent=(-1.5, 1.5, -1.5, 1.5), alpha=1, vmin=-.2,vmax=.2, cmap='bwr')

#plt.contour(px,py,plane.reshape(npx,npy))
CL1= plt.contour(px,py,plane.reshape(npx,npy),np.arange(0.05,10,0.02), colors=["black"])
CL2= plt.contour(px,py,plane.reshape(npx,npy),[0], colors=["red"])
CL3= plt.contour(px,py,plane.reshape(npx,npy),np.arange(-0.05,-10,-0.02), colors=["blue"])


plt.grid(True)
plt.tick_params(size=10,width=1.5,pad=20, labelsize=22)

plt.savefig("CHGCAR.ps")

plt.ion()
plt.show()







Loading

0 comments on commit b615ca7

Please sign in to comment.