Skip to content

Instantly share code, notes, and snippets.

@unkcpz
Last active August 9, 2016 02:01
Show Gist options
  • Save unkcpz/f18ae331f543f7e1c8339354c5a0fb68 to your computer and use it in GitHub Desktop.
Save unkcpz/f18ae331f543f7e1c8339354c5a0fb68 to your computer and use it in GitHub Desktop.
auto script for epsilon.x and yambo-preload calculation.
#!/usr/bin/env perl
##
## convge test for parameter NGsBlkXd from 50..250
$NAME = "zns-z";
@n = (50,100,150,200,250);
foreach $blk (@n){
# loop write the input yambo
open INFILE, ">yambo.in" or die $!;
print INFILE << "END";
optics # [R OPT] Optics
chi # [R CHI] Dyson equation for Chi.
Chimod= "Hartree" # [X] IP/Hartree/ALDA/LRC/BSfxc
NGsBlkXd= $blk RL # [Xd] Response block size
% QpntsRXd
1 | 1 | # [Xd] Transferred momenta
%
% BndsRnXd
1 | 78 | # [Xd] Polarization function bands
%
% EnRngeXd
0.00000 | 10.00000 | eV # [Xd] Energy range
%
% DmRngeXd
0.10000 | 0.10000 | eV # [Xd] Damping range
%
ETStpsXd= 100 # [Xd] Total Energy steps
% LongDrXd
0.000000 | 0.000000 | 1.000000 | # [Xd] [cc] Electric Field
%
END
close INFILE;
# run yambo and extract the results
system "/share/home/WuLM/yjs/local/yambo-3.4/yambo -F yambo.in -J $NAME";
open RES, "<o-$NAME.eps_q1_inv_rpa_dyson" or die $!;
while (my $line = <RES>){
if ($line =~ m/^\s+0.000000/) {
my @column = split(/\s+/, $line);
$epsr = $column[3];
last;
}
}
close RES;
open COM, ">>comment_$NAME" or die $!;
print COM "$blk\t$epsr";
close COM;
}
#!/bin/bash
PSEUDO_DIR="/share/home/WuLM/yjs/pwscf/pseudo/"
PW_COMMAND="mpiexec.hydra -n 32 pw.x"
EPS_COMMAND="epsilon.x"
NAME="snse" #
ECHO="echo"
cutoff=80
cat > $NAME.scf.in << EOF
&CONTROL
calculation = "scf"
pseudo_dir = '$PSEUDO_DIR' ,
prefix = '$NAME' ,
wf_collect = .true.
/
&SYSTEM
occupations = 'fixed' ,
smearing = 'methfessel-paxton' ,
input_dft = 'pbe',
ibrav = 4
celldm(1) = 19.171,
celldm(3) = 0.912,
nat = 30
ntyp = 4
ecutwfc = $cutoff,
use_all_frac = .true. ,
/
&ELECTRONS
conv_thr = 1.0d-8,
/
ATOMIC_SPECIES
Ga 69.72300 Ga_ONCV_PBE-1.0.upf
Ba 137.32700 Ba_ONCV_PBE-1.0.upf
Se 78.96000 Se_ONCV_PBE-1.0.upf
Sn 118.71000 Sn_ONCV_PBE-1.0.upf
ATOMIC_POSITIONS {crystal}
Ba 0.991062 0.335848 0.962037
Ba 0.344786 0.008938 0.628704
Ba 0.664152 0.655214 0.295371
Ga 0.854747 0.608619 0.680179
Ga 0.433340 0.473985 0.690542
Ga 0.753871 0.145253 0.346846
Ga 0.040644 0.566660 0.357209
Ga 0.526015 0.959356 0.023875
Ga 0.391381 0.246129 0.013513
Sn 0.714337 0.902336 0.683219
Sn 0.187999 0.285663 0.349885
Sn 0.097664 0.812001 0.016552
Se 0.076954 0.594275 0.611115
Se 0.188067 0.252892 0.620766
Se 0.738997 0.156892 0.605381
Se 0.417895 0.261003 0.272047
Se 0.517321 0.923046 0.277782
Se 0.064825 0.811933 0.287433
Se 0.747108 0.935175 0.954099
Se 0.843108 0.582105 0.938714
Se 0.405725 0.482679 0.944449
Se 0.917048 0.853166 0.572550
Se 0.615362 0.420141 0.576586
Se 0.461063 0.701833 0.571427
Se 0.240770 0.538937 0.238094
Se 0.936117 0.082952 0.239216
Se 0.804779 0.384638 0.243253
Se 0.579859 0.195221 0.909920
Se 0.298167 0.759230 0.904761
Se 0.146834 0.063883 0.905883
K_POINTS automatic
4 4 4 1 1 1
EOF
$ECHO " running the scf calculation..."
$PW_COMMAND < $NAME.scf.in > $NAME.scf.out
vbands=`grep 'number of Kohn-Sham states' $NAME.scf.out | awk '{print $NF}'`
$ECHO " $vbands v bands"
abands=$(echo "$vbands*3" | bc)
$ECHO " use $abands in nscf for optical properties"
# nscf
cat > $NAME.nscf.in << EOF
&CONTROL
calculation = "nscf"
pseudo_dir = '$PSEUDO_DIR' ,
prefix = '$NAME' ,
wf_collect = .true.
/
&SYSTEM
occupations = 'fixed' ,
smearing = 'methfessel-paxton' ,
input_dft = 'pbe',
ibrav = 4
celldm(1) = 19.171,
celldm(3) = 0.912,
nat = 30
ntyp = 4
ecutwfc = $cutoff,
nbnd = $abands,
nosym = .true. ,
noinv = .true.,
force_symmorphic = .true. ,
/
&ELECTRONS
conv_thr = 1.0d-9,
/
ATOMIC_SPECIES
Ga 69.72300 Ga_ONCV_PBE-1.0.upf
Ba 137.32700 Ba_ONCV_PBE-1.0.upf
Se 78.96000 Se_ONCV_PBE-1.0.upf
Sn 118.71000 Sn_ONCV_PBE-1.0.upf
ATOMIC_POSITIONS {crystal}
Ba 0.991062 0.335848 0.962037
Ba 0.344786 0.008938 0.628704
Ba 0.664152 0.655214 0.295371
Ga 0.854747 0.608619 0.680179
Ga 0.433340 0.473985 0.690542
Ga 0.753871 0.145253 0.346846
Ga 0.040644 0.566660 0.357209
Ga 0.526015 0.959356 0.023875
Ga 0.391381 0.246129 0.013513
Sn 0.714337 0.902336 0.683219
Sn 0.187999 0.285663 0.349885
Sn 0.097664 0.812001 0.016552
Se 0.076954 0.594275 0.611115
Se 0.188067 0.252892 0.620766
Se 0.738997 0.156892 0.605381
Se 0.417895 0.261003 0.272047
Se 0.517321 0.923046 0.277782
Se 0.064825 0.811933 0.287433
Se 0.747108 0.935175 0.954099
Se 0.843108 0.582105 0.938714
Se 0.405725 0.482679 0.944449
Se 0.917048 0.853166 0.572550
Se 0.615362 0.420141 0.576586
Se 0.461063 0.701833 0.571427
Se 0.240770 0.538937 0.238094
Se 0.936117 0.082952 0.239216
Se 0.804779 0.384638 0.243253
Se 0.579859 0.195221 0.909920
Se 0.298167 0.759230 0.904761
Se 0.146834 0.063883 0.905883
K_POINTS automatic
4 4 4 1 1 1
EOF
$ECHO " running the nscf calculation..."
$PW_COMMAND < $NAME.nscf.in > $NAME.nscf.out
# epsilon.x
cat > $NAME.eps.in << EOF
&inputpp
prefix='$NAME',
calculation='eps',
/
&energy_grid
smeartype=’gauss’
intersmear=0.136d0
intrasmear=0.0d0
wmax=10.0d0
wmin=0.0d0
nw=1001
shift=0d0
/
EOF
$ECHO " running epsilon calculation..."
$EPS_COMMAND < $NAME.eps.in > $NAME.eps.out
for FILENAME in *.dat; do mv $FILENAME $NAME_$FILENAME;done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment