[Wien] runafm_lapw ver 19.1

Peter Blaha pblaha at theochem.tuwien.ac.at
Wed Oct 9 15:47:01 CEST 2019


Hi,

I can confirm the problems. The runafm_lapw script of WIEN2k_19 (and 18) 
has at least 2 (or 3) bugs related to the use of case.inm_vresp.

The variable vresp is not set by default.
vresp was only redefined in cases with inversion symmetry (lapw2 but not 
in lapw2c section).
The if statement concerning vresp may not work on all csh/tcsh versions.

I attach a new version of the script.

Thank's for the message,

Regards

On 10/9/19 1:02 PM, Takuma Ogasawara wrote:
> Dear Wien2k users,
> 
> I got a strange error massage
> 
> "vresp: Undefined variable."
> 
> during runafm_lapw btw lapw1 and lapw2 without any other option
> (where I just use spin ).
> As I know, case.vresp is used for advansed option such as mJB.
> And I can do non magnetic scf calculation using run_lapw with same 
> crystal structure.
> Thus I guess there are something wrong in runafm_lapw.
> 
> I find "set versp" on line 438 and 440 in runafm_lapw.
> It suggest some other command loaded before this definition line.
> Actually, when I move these lines to 195 that is just below the lines 
> that define other variables,
> I confirm runafm_lapw works without error.
> 
> Anyway, I think runafm_lapw contains something wrong.
> But I cannot clarify what is wrong due to my poor knowledge.
> Could anyone check about it?
> 
> Thanks in advance.
> 
> with regards,
> 
> Takuma Ogasawara
> ------------------
> Dept. Phys., Faculty of Sci., Tohoku Univ.
> Nano Solid State Physics Lab.
> Zipcode:980-8577 2-1-1, Katahira, Aoba-ku, Sendai-shi, Miyagi-prefecture
> Tohoku University, WPI-AIMR main building, Floor 3, Room 3B
> Zipcode980-8578 6-3, Aza-Aoba, Aramaki, Aoba-ku, Sendai-shi,
> Miyagi-prefecture
> Tohoku University, Department of Physics, Building A, Room 319
> 
> mail: takuma.ogasawara.s4 at dc.tohoku.ac.jp
> TEL: +81 090-1542-3269
> -------------------
> 
> 
> _______________________________________________
> Wien mailing list
> Wien at zeus.theochem.tuwien.ac.at
> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
> 

-- 

                                       P.Blaha
--------------------------------------------------------------------------
Peter BLAHA, Inst.f. Materials Chemistry, TU Vienna, A-1060 Vienna
Phone: +43-1-58801-165300             FAX: +43-1-58801-165982
Email: blaha at theochem.tuwien.ac.at    WIEN2k: http://www.wien2k.at
WWW:   http://www.imc.tuwien.ac.at/TC_Blaha
--------------------------------------------------------------------------
-------------- next part --------------
#!/bin/tcsh -f
hup
unalias rm

set name  = $0
set bin   = $name:h		#directory of WIEN-executables
if !(-d $bin) set bin = .
set name  = $name:t 		#name of this script-file
set logfile = :log
set tmp   = (:$name)		#temporary files

set scratch =                   # set directory for vectors and help files
set scratchstring =
if ($?SCRATCH) then              #if envronment SCRATCH is set
 set scratch=`echo $SCRATCH  | sed -e 's/\/$//'`/ #set $scratch to that value  
endif                          

#---> path- and file-names
set file    = `pwd`
set file    = $file:t		#tail of file-names
set dayfile = $file.dayfile	#main output-file

#---> functions & subroutines
alias	testinput	'set errin="\!:1";if (! -e \!:1 || -z \!:1) goto \!:2'
alias	teststatus	'if ($status) goto error'
alias	testerror	'if ( -e \!:1.error && ! -z \!:1.error) goto error'
alias	teststop	'if (\!:1 == $stopafter ) goto stop'
alias   cleandayfile    'grep -v "\[" $dayfile >.tmp;'\
                        'mv .tmp $dayfile'
alias	output		'set date = `date +"(%T)"`;'\
			'printf ">   %s\t%s " "\!:*" "$date" >> $dayfile'

alias	exec		'($bin/x  \!:*) >> $dayfile;'\
			'teststatus'

alias	total_exec	'output \!:*;'\
			'exec \!:*;'\
                        'cleandayfile;'\
			'testerror \!:1;'\
			'testerror up\!:1;'\
			'testerror dn\!:1;'\
			'teststop \!:1'
alias	TOTtoFOR	'sed "s/TOT/FOR/" \!:1 > $tmp;'\
			'mv $tmp \!:1'
alias	FORtoTOT	'sed "s/FOR/TOT/" \!:1 > $tmp;'\
			'mv $tmp \!:1'

#---> default parameters
set ccut	= 0.0000 	#upper limit for charge convergence
set fcut	= 0 	 	#upper limit for force convergence
set ecut	= 0.0001	#upper limit for energy convergence
set eece1
set eece2
unset eece
unset ec_conv
set cc_conv
set fc_conv
set ec_test
unset ec_test1
unset cc_test
unset fc_test
set iter	= 40	#maximum number of iterations
set riter	= 99	#restart after $riter iterations
set stopafter		#stop after $stopafter
set next		#set -> start cycle with $next
set qlimit = 0.05       #set -> writes E-L in new in1 when qlimit is fulfilled
set in1new = 999
set write_all = -ef     # new default: -in1ef is activated (version 10.1)
set para
set nohns
set nohns1 = 0
set it
set readHinv
unset vec2pratt
set it0
set itnum=0
set itnum1=0
set so
set broyd
set orb
unset orbc
set ctest=(0 0 0)
set etest=(0 0 0)
set msrcount=0
set vresp

#---> default flags
unset renorm
set   in1orig
unset force		#set -> force-calculation after self-consistency
unset f_not_conv
unset help		#set -> help output
unset complex		#set -> complex calculation
unset init		#set -> switches initially set to total energy calc.

#---> handling of input options
echo ">   ($name) options: $argv"	>> $logfile
set commandline=`echo "$name $argv " `
alias sb 'shift; breaksw'	#definition used in switch
while ($#argv)
  switch ($1)
  case -[H|h]:
    set help; sb
  case -so:
    echo 'so not supported with AFM calculations'
    exit 3
       set so = -so; sb
  case -nohns:
    set nohns = -nohns; shift; set nohns1 = $1;sb
  case -orb:
#    echo 'orb not supported with AFM calculations'
#    exit 3
    set orb = -orb; sb
  case -eece:
    set eece
    set eece1 = -orb ; set eece2 = -eece ; sb
  case -orbc:
    set orbc
    set orb = -orb; sb
  case -it:
    set itnum = 99; set it = -it; set it0 = -it; sb
  case -it1:
    set itnum = 99; set it = -it; set it0 = -it; touch .noHinv; sb
  case -it2:
    set itnum = 99; set it = -it; set it0 = -it; touch .fulldiag; sb
  case -noHinv:
    set itnum = 99; set it = -it; set it0 = -it; set readHinv = -noHinv; sb
  case -vec2pratt:
    set vec2pratt; sb
  case -p:
    set para = -p; sb
  case -I:
    set init; sb
  case -NI:
    unset broyd; sb
  case -e: 
    shift; set stopafter = $1; sb
  case -cc: 
    shift; set ccut = $1; set cc_test;unset cc_conv; sb
  case -ec: 
    shift; set ecut = $1; set ec_test1;unset ec_conv; sb
  case -fc: 
    shift; set f_not_conv; set fcut = $1; set fc_test;unset fc_conv; sb
  case -min:
    sed "s/MSR1 /MSR1a/" $file.inm |sed "1s/MSEC3 /MSECa /" | sed "s/9999 *8/9999  10/"> $file.inm_msr1a; cp $file.inm_msr1a  $file.inm; sb
  case -ql: 
    shift; set qlimit = $1;  sb
  case -in1ef: 
    set in1new = -1;set write_all = -ef;  sb
  case -in1new: 
    shift; set in1new = $1;set write_all;  sb
  case -in1orig:
    set in1orig = -in1orig; set in1new = 999; sb
  case -renorm: 
    set renorm; set next=mixer;  sb
  case -i:
    shift; set iter  = $1; sb
  case -r:
    shift; set riter = $1; sb
  case -s:
    shift; set next  = $1; sb
  case -scratch:
    shift;set scratch = $1
    set ncar=`echo $scratch |wc -m`
    @ ncar --
    set lcar=`echo $scratch | cut -c$ncar`
    if("$lcar" != '/' ) set scratch=`echo "${scratch}/"`
    set scratchstring="-scratch $scratch"
    setenv SCRATCH $scratch
    if ( "$scratch" == "./" ) then
        set scratch=
        set scratchstring=
    else if(! -e "$scratch" ) then
        mkdir -p $scratch
    endif
    shift; breaksw  
  default: 
    echo "ERROR: option $1 does not exist\!"; sb
  endsw
end
if ($?help) goto help

if($?cc_test) then
       unset ec_test;set ec_conv
endif
if($?fc_test) then
       unset ec_test;set ec_conv
endif
if($?ec_test1) then
       set ec_test;unset ec_conv
endif
if(! $?ec_test) then
       set ecut=0
endif
 
set vresp
testinput       $file.inm_vresp no_vresp
set vresp=-vresp
no_vresp:

#---> starting out
printf "\nCalculating $file in `pwd`\non `hostname` with PID $$\n"  > $dayfile
echo "using `cat $WIENROOT/WIEN2k_VERSION` in $WIENROOT"  >> $dayfile
printf "\n:LABEL1: Calculations in `pwd`\n:LABEL2: on `hostname` at `date`\n"  >> $file.scf
echo ":LABEL3: using `cat $WIENROOT/WIEN2k_VERSION` in $WIENROOT\n"  >> $file.scf
echo ":LABEL4: using the command: $commandline\n"  >> $file.scf

# set iter/riter to 999 when MSR1a/MSECa is used
set testmsr=`head -1 $file.inm | grep "MSR[12]a" | cut -c1-3`
set testmsr1=`head -1 $file.inm | grep "MSECa" | cut -c1-5`
if($testmsr1 == 'MSECa') set testmsr=MSR
if ($testmsr == 'MSR') then
   if($riter == "99") set riter=999 
   if($iter == "40")  set iter=999 
   foreach i ($file.in2*)
        TOTtoFOR $i             #switch FOR-label
        echo changing TOT to FOR in $i
   end
   if (! -e $file.inM &&  ! -z $file.inM ) then
     x pairhess
     echo $file.inM  and .minrestart have been created by pairhess >>$dayfile
   endif
   if( $fcut == "0" ) then
      set fcut = 1.0
   endif
   set f_not_conv; set fc_test;unset fc_conv
#  Added by LDM, force AFM
   total_exec struct_afm_check
   cp $file.struct_afm_check $file.struct   
endif

if ($next != "") goto start	#start with optional program
set next = lapw0		#default start with lstart

if !(-e $file.clmsum) then
   if (-e $file.clmsum_old) then
    cp $file.clmsum_old $file.clmsum
   else
     echo 'no' $file'.clmsum(_old) file found, which is necessary for lapw0 \!'
     echo 'no' $file'.clmsum(_old) file found, which is necessary for lapw0 \!'\
	>>$dayfile
     goto error
   endif
endif

if ($?broyd) then
   if (-e $file.broyd1) then
     echo "$file.broyd* files present \! You did not save_lapw a previous clculation."  
     echo "You have 60 seconds to kill this job ( ^C   or   kill $$ )"  
     echo "or the script will rm *.broyd* and continue (use -NI to avoid automatic rm)"
      sleep 60
     rm *.broyd*
     echo "$file.broyd* files removed \!"  >> $dayfile
   endif
endif

#check consistency of struct file
testinput       $file.inclmcopy error_input
total_exec struct_afm_check
set test=`grep from $file.outputstruct_afm_check`
if ( $#test > 1 ) then
  echo "$file.struct symmetry adapted by struct_afm_check" >> $dayfile
  cp $file.struct_afm_check $file.struct
endif


start:				#initalization of in2-files
if ($?init && $testmsr != 'MSR' ) then
  foreach i ($file.in2*)
    sed "1s/[A-Z]..../TOT  /" $i > $tmp
    mv $tmp $i
  end
endif

set icycle=1

set riter_save=$riter
printf "\n\n    start \t(%s) " "`date`" >> $dayfile
echo  "with $next ($iter/$riter to go)"	>> $dayfile
goto $next

cycle:					#begin of sc-cycle
nohup echo in cycle $icycle "   ETEST: $etest[3]   CTEST: $ctest[3]"
hup

if ($it == '-it' ) then
 set ittest=`echo "$icycle / $itnum * $itnum "| bc`
 if ( $ittest == $icycle ) touch .fulldiag
endif

lapw0:
printf "\n    cycle $icycle \t(%s) \t(%s)\n\n" "`date`" "$iter/$riter to go" 	>> $dayfile

testinput       $file.in0_grr cont_lapw0
total_exec      lapw0 -grr $para

cont_lapw0:
testinput	$file.in0 error_input

#fix for NFS bug
touch $file.vspup $file.vspdn $file.vnsup $file.vnsdn
rm $file.vspup $file.vspdn $file.vnsup $file.vnsdn

total_exec	lapw0 $para

if ($fcut == "0") goto orb
set f_exist=`grep :FHF $file.scf0`
if ($#f_exist == 0 ) then
  set fcut=0
  set fc_conv
  echo Force-convergence not possible. Forces not present.
  echo Force-convergence not possible. Forces not present.>> $dayfile
  if($?ec_test) goto orb
  if($?cc_test) goto orb
  goto error
endif

#---> test of force-convergence for all forces
if !(-e $file.scf) goto orb
set natom=`head -2 $file.struct |tail -1 |cut -c28-30`
#set natom = `grep UNITCELL $file.output0 |awk '{print $NF}'`
set iatom = 1
set ftest = (1 0)
while ($iatom <= $natom) 		#cycle over all atoms 
  if ($iatom <= 9) then
      set test = (`$bin/testconv -p :FOR00$iatom -c $fcut`)	
  else if ($iatom <= 99) then
      set test = (`$bin/testconv -p :FOR0$iatom -c $fcut`)	
   else
      set test = (`$bin/testconv -p :FOR$iatom -c $fcut`)	
  endif
  if  !($test[1]) set ftest[1] = 0
  set ftest[2] = $test[2]
  set ftest    = ($ftest $test[3] $test[4])
  @ iatom ++
end
echo ":FORCE convergence:"  $ftest[1-]			>> $dayfile

if ($ftest[1]) then			#force convergenced
  if ($nohns == '-nohns') then			#force convergenced
      set nohns 
      echo "NOHNS deactivated by FORCE convergence"		>> $dayfile
  else
#      set iter = 1
      if(! $?ec_conv) goto orb 
      if(! $?cc_conv) goto orb
      set fc_conv
      unset f_not_conv 
      foreach i ($file.in2*)
        TOTtoFOR $i				#switch FOR-label
      end
  endif
else
      unset fc_conv
endif

orb:
foreach i (dmatup dmatdn dmatud )
  if (-e $file.$i"_old" ) rm $file.$i"_old"	
  if (-e $file.$i ) cp $file.$i $file.$i"_old"		#save this cycle for next
end

if ( -e $file.scforbup ) rm $file.scforbup 
if ( -e $file.scforbdn ) rm $file.scforbdn 
if ( -e $file.scforbud ) rm $file.scforbud 
if ( -e $file.vorbud   ) rm $file.vorbud

if ( "$orb" != "-orb" ) goto lapw1
if ( $?orbc ) goto lapw1
if (! -e $file.dmatup || -z $file.dmatup ) goto lapw1
#foreach i ( vorbup vorbdn vorbud )
#  if (-e $file.$i ) \
#  cp $file.$i $file.$i"_old"		#save last cycle
#end
testinput	$file.inorb error_input
total_exec	orb -up $para
total_exec	orb -dn $para
#if ( "$so" == "-so" && -s $file.dmatud ) then
if ( "$so" == "-so" && ! -z $file.dmatud && -e $file.dmatud ) then
   if( $?orbud ) then
      total_exec	orb -ud $para
# vorbud seems unphysical large, so we use it only with -orbud switch)
   endif
endif


lapw1:
testinput	$file.in1 lapw1c
set readHinv0 = $readHinv
if (-e .noHinv) then
  echo "    case.storeHinv files removed"
  set readHinv0 = -noHinv0
  rm .noHinv
endif
if (-e .fulldiag) then
  echo "    full diagonalization forced"
  set it0
  set readHinv0
  rm .fulldiag
  rm -f  ${scratch}$file.vector*.old
endif
if ( $it0 == "-it" ) then
  touch ${scratch}$file.vector.old
  if( ! $?vec2pratt ) then
   foreach i (${scratch}$file.vector*.old)
    rm $i
   end
    vec2old_lapw $para -up >> $dayfile
#    if ( $?eece ) vec2old_lapw $para -dn >> $dayfile
  else
    vec2pratt_lapw $para -up >> $dayfile
#    if ( $?eece ) vec2pratt_lapw $para -dn >> $dayfile
  endif
endif

#generates in1-file from :EPL/EPH in case.scf2 
#  if ($icycle == $in1new) rm $file.broyd1 $file.broyd2 
  if ($icycle >= $in1new ) then
    if (! -e $file.in1_orig ) cp $file.in1 $file.in1_orig
    write_in1_lapw $write_all -up -ql $qlimit >> $dayfile
    if($status == 0 ) cp $file.in1new $file.in1
  endif
if($?in1orig == '-in1orig') then
    if ( -e $file.in1_orig ) mv $file.in1_orig $file.in1
#    unset in1orig
endif
total_exec	lapw1 $it0 -up $para $nohns $orb $readHinv0 $scratchstring $eece1
#total_exec	lapw1 $it0 -dn $para $nohns
copyvec:
#  vec2old_lapw $para -updn >> $dayfile
  foreach i ( $file.energyup* )
  if (! -z $i ) then
    set new = `echo $i|sed "s/energyup/energydn/"`
    cp $i $new
  endif
  end

cp $file.nshup $file.nshdn                                                   
set it0 = $it
set readHinv0 = $readHinv

lapw2:
testinput	$file.in2 error_input
total_exec	lapw2 -up $para $vresp $in1orig $scratchstring
#if ( $?eece ) then
#    total_exec	lapw2 -dn $para $vresp $in1orig $scratchstring
#endif
#total_exec	lapw2 -dn $para $vresp $in1orig
rm -f $file.clmsc

lapwdm:
#  should be removed and -orb added to lapw2 step !
if ( -e $file.scfdmup ) rm $file.scfdmup 
if ( -e $file.scfdmdn ) rm $file.scfdmdn
if ( "$orb" != "-orb" ) goto clmcopya
if ( $?orbc ) goto clmcopya
testinput	$file.indm error_input
total_exec	lapwdm -up $para $scratchstring
##total_exec	lapwdm -dn $para

clmcopya:
testinput	$file.inclmcopy error_input
total_exec      clmcopy
if ( "$vresp" == '-vresp' ) then
    total_exec  clmcopy -vresp
endif

lapw1s:
testinput	$file.in1s lcore
total_exec	lapw1 -sc -up $para $nohns $scratchstring
total_exec	lapw1 -sc -dn $para $nohns  $scratchstring

lapw2s:
testinput	$file.in2s error_input
total_exec	lapw2 -sc -up $para $vresp $in1orig $scratchstring
total_exec	lapw2 -sc -dn $para $vresp $in1orig $scratchstring
goto lcore

lapw1c:
testinput	$file.in1c error_input
set readHinv0 = $readHinv
if (-e .noHinv) then
  echo "    case.storeHinv files removed"
  set readHinv0 = -noHinv0
  rm .noHinv
endif
if (-e .fulldiag) then
  echo "    full diagonalization forced"
  set it0
  set readHinv0
  rm .fulldiag
endif
if ( $it0 == "-it" ) then
  touch ${scratch}$file.vector.old
  if( ! $?vec2pratt ) then
   foreach i (${scratch}$file.vector*.old)
    rm $i
   end
    vec2old_lapw $para -up >> $dayfile
  else
    vec2pratt_lapw $para -up >> $dayfile
  endif
endif
#generates in1-file from :EPL/EPH in case.scf2 
#  if ($icycle == $in1new) rm $file.broyd1 $file.broyd2 
  if ($icycle >= $in1new ) then
    if (! -e $file.in1c_orig ) cp $file.in1c $file.in1c_orig
    write_in1_lapw $write_all -up -c -ql $qlimit >> $dayfile
    if($status == 0 ) cp $file.in1cnew $file.in1c
  endif
if($?in1orig == '-in1orig') then
    if ( -e $file.in1c_orig ) mv $file.in1c_orig $file.in1c
#    unset in1orig
endif
total_exec	lapw1 $it0 -c -up $para $nohns $orb $readHinv0 $scratchstring $eece1
copyvecc:
#  vec2old_lapw $para -updn >> $dayfile
  foreach i ( $file.energyup* )
  if (! -z $i ) then
    set new = `echo $i|sed "s/energyup/energydn/"`
    cp $i $new
  endif
  end
cp $file.nshup $file.nshdn                                                   

set it0 = $it
set readHinv0 = $readHinv

lapw2c:
testinput	$file.in2c error_input
total_exec	lapw2 -c -up $so $para $vresp $in1orig $scratchstring
#if ( $?eece ) then
#  total_exec  lapw2  -c -dn $so $para $vresp $in1orig $scratchstring
#endif
rm -f $file.clmsc

lapwdmc:
if ( -e $file.scfdmup ) rm $file.scfdmup 
if ( -e $file.scfdmdn ) rm $file.scfdmdn
testinput	$file.in2c error_input
if ( ! $?dm ) then 
 if ( "$orb" != "-orb" ) goto clmcopyc
 if ( $?orbc ) goto clmcopyc
endif
testinput	$file.indmc error_input
total_exec	lapwdm -up $para $so -c $scratchstring

clmcopyc:
testinput	$file.inclmcopy error_input
total_exec      clmcopy
if ( "$vresp" == '-vresp' ) then
   total_exec   clmcopy -vresp
endif

lapw1cs:
testinput	$file.in1cs lcore
total_exec	lapw1 -c -sc -up $para $nohns $scratchstring
total_exec	lapw1 -c -sc -dn $para $nohns $scratchstring

lapw2cs:
testinput	$file.in2cs error_input
total_exec	lapw2 -c -sc -up $para $vresp $in1orig $scratchstring
total_exec	lapw2 -c -sc -dn $para $vresp $in1orig $scratchstring

lcore:
testinput	$file.inc scf
total_exec	lcore -up
total_exec	lcore -dn

coresuper:
   if ( ! -e .lcore) goto scf
   total_exec      dstart -lcore -up $para
   total_exec      dstart -lcore -dn $para
   rm $file.clmcorup $file.clmcordn

scf:
foreach i ( 0 orbup orbdn orbud 1up  2up 2dn dmup dmdn 1sup 1sdn 2sup 2sdn cup cdn )
  if (-e $file.scf$i) cat $file.scf$i  >> $file.scf
end
foreach i (dmatup dmatdn dmatud )
  if (-e $file.$i"_unmixed" ) rm $file.$i"_unmixed"	
  if (-e $file.$i ) cp $file.$i $file.$i"_unmixed"	#save the unmixed dmat
end
scf1:
foreach i (clmsum clmup clmdn vspup vspdn vnsup vnsdn )
  if (-e $file.$i ) \
	cp $file.$i $file.$i"_old"		#save last cycle
end

# LDM Addition for eece
# Copy weightup to down (perhaps better in general...)  ? wozu
if( ! $?eece ) then
cp $file.weightup $file.weightdn
  foreach i ( $file.weightup* )
  if (! -z $i) then
    set j=`echo $i:e | cut -d _ -f 2- -s`
    if ( $j ) then
      cp $file.weightup_$j $file.weightdn_$j
    else
      cp $file.weightup $file.weightdn
    endif
  endif
  end
endif
#
if ( $?eece ) then
   mv $file.scf2up $file.scf2up-tmp
   mv $file.scf2dn $file.scf2dn-tmp
   if( "$vresp" == '-vresp' ) then
     mv $file.vrespvalup $file.vrespvalup-tmp
     mv $file.vrespvaldn $file.vrespvaldn-tmp
     mv $file.vrespcorup $file.vrespcorup-tmp
     mv $file.vrespcordn $file.vrespcordn-tmp
   endif
   foreach i ( vorbup vorbdn vorbdu )
     if (-e $file.$i"_old" ) rm $file.$i"_old"  
     if (-e $file.$i )   cp $file.$i $file.$i"_old"     #save last cycle
   end
   runeece_lapw   $so $para $vresp -afm
   teststatus
   foreach i (vorbup vorbdn vorbud )
     if (-e $file.$i"_unmixed" ) rm $file.$i"_unmixed"  
     if (-e $file.$i ) cp $file.$i $file.$i"_unmixed"   #save unmixed dmat
   end
   mv $file.scf2up $file.scf2upeece
   mv $file.scf2dn $file.scf2dneece
   mv $file.scf2up-tmp $file.scf2up
   mv $file.scf2dn-tmp $file.scf2dn
   if( "$vresp" == '-vresp' ) then
     mv $file.vrespvalup $file.vrespvaleeceup
     mv $file.vrespvaldn $file.vrespvaleecedn
     mv $file.vrespvalup-tmp $file.vrespvalup
     mv $file.vrespvaldn-tmp $file.vrespvaldn
     mv $file.vrespcorup-tmp $file.vrespcorup
     mv $file.vrespcordn-tmp $file.vrespcordn
   endif
endif


mixer:
testinput	$file.inm error_input
if ( $?orbc ) then
    total_exec  mixer
else
    total_exec	mixer $eece1 $eece2 $orb
endif
total_exec      clmcopy -sum
cat $file.scfm >> $file.scf

if ( -e .forcedmat ) then
   cp $file.dmatup_unmixed $file.dmatup
   cp $file.dmatdn_unmixed $file.dmatdn
   rm .forcedmat
endif
if ( -e .forceorb ) then
   cp $file.vorbup_unmixed $file.vorbup
   cp $file.vorbdn_unmixed $file.vorbdn
   rm .forceorb
endif

if($?renorm) then
   unset renorm
   rm $file.broy*
endif

mixer_vresp:
testinput       $file.inm_vresp energytest
total_exec      mixer_vresp
grep -e "CTO " -e NEC $file.outputm_vresp | sed 's/:/:VRESP/' >> $file.scf
#total_exec      int16

energytest:
#---> output energies
#set EF = `grep 'F E R' $file.scf2    |awk '{printf("%.5f", $NF)}'`
#set ET = `grep 'AL EN' $file.outputm |awk '{printf("%.5f", $NF)}'`
#cat << theend				>> $dayfile
#EF  $EF
#ET  $ET
#theend
#echo $ET 				> $file.finM

#---> test of energy convergence
#if ($ecut == "0") goto chargetest
set etest = (`$bin/testconv -p :ENE -c $ecut`)	
teststatus
echo ":ENERGY convergence:  $etest[1-3]"		>> $dayfile
if (! $?ec_test) goto chargetest
if ($etest[1]) then
  if ($nohns == '-nohns') then
      set nohns 
      echo "NOHNS deactivated by ENERGY convergence"		>> $dayfile
  else
#      set iter = 1
      set ec_conv
  endif
else
      unset ec_conv
endif

chargetest:
#if ($ccut == "0") goto nextiter
set ctest = (`$bin/testconv -p :DIS -c $ccut`)	
teststatus
echo ":CHARGE convergence:  $ctest[1-3]"		>> $dayfile
if (! $?cc_test) goto testmsr
#if (! $?cc_test) goto nextiter
if ($ctest[1]) then
  if ($nohns == '-nohns') then
      set nohns 
      echo "NOHNS deactivated by CHARGE convergence"		>> $dayfile
  else
#      set iter = 1
      set cc_conv
  endif
else
      unset cc_conv
endif

# check F-condition for MSR1a mode
testmsr:
if ($testmsr == 'MSR') then
# Added, force AFM
  total_exec struct_afm_check
  cp $file.struct_afm_check $file.struct  
  set msrtest =(`grep :FRMS $file.scf |tail -1` )
  if ($#msrtest >= 13 ) then
    echo msrcount $msrcount msrtest $msrtest[13]
#   Trap silly early convergene with "minimum-requests"
    set etest2 = (`$bin/testconv -p :ENE -c 0.001`)
    if ( $etest2[1] == '0')set msrtest[13]='F'
    set ctest2 = (`$bin/testconv -p :DIS -c 0.01`)
    if ( $ctest2[1] == '0')set msrtest[13]='F'
#
    if ($msrtest[13] == 'T') then
    #change in case.inm MSR1a/MSECa to MSR1/MSEC3, rm *.bro*, unset testmsr
@     msrcount ++
      if($msrcount == 3) then
        sed "1s/MSR1a/MSR1 /" $file.inm | sed "s/9999 *10/9999  8/" >$file.inm_tmp
        sed "1s/MSECa/MSEC3/" $file.inm_tmp >$file.inm
        rm *.broy* $file.inm_tmp
        set a=`grep -e GREED *scfm | tail -1 | cut -c 50-55`
        set b=`echo "scale=5; if( $a/2 > 0.05) $a/2  else 0.05 " |bc -l`
        echo $b > .msec
        echo "MSR1a/MSECa changed to MSR1/MSEC3 in $file.inm, relaxing only electrons" >> $dayfile
        set testmsr
      endif
    else
      set msrcount=0
    endif
  endif
endif


#---> output forces
#grep 'FTOT' $file.outputm|awk '{print "FT ",$2,$4,$5,$6}'\
#					>> $dayfile
#grep 'FTOT' $file.outputm|awk '{print $4,$5,$6}' \
#					>> $file.finM	

nextiter:
@  iter --
@ riter --
@ nohns1 --
@ icycle ++

#---> nohns
if (! $nohns1 ) then
  set nohns
  echo "NOHNS deactivated" 			>> $dayfile
endif

#---> restart
if (! $riter && -e $file.broyd1) then
  echo "    restart" 			>> $dayfile
  rm $file.broyd1 $file.broyd2
  set riter=$riter_save
endif

foreach i ($tmp)			#delete temporary files
  if (-e $i) rm $i
end

#output		cycle
#printf "%s\n\n" "$iter/$riter to go" 	>> $dayfile
if (-e .stop) goto stop1

if ($testmsr == 'MSR' && -e .minstop) then
        sed "1s/MSR1a/MSR1 /" $file.inm >$file.inm_tmp
        sed "1s/MSECa/MSEC3/" $file.inm_tmp >$file.inm
        rm *.broy* $file.inm_tmp .minstop
        set a=`grep -e GREED *scfm | tail -1 | cut -c 50-55`
        set b=`echo "scale=5; if( $a/2 > 0.05) $a/2  else 0.05 " |bc -l`
        echo $b > .msec
        echo "MSR1a/MSECa changed to MSR1/MSEC3 in $file.inm, relaxing only electrons" >> $dayfile
        set testmsr
endif

echo ec cc and fc_conv $?ec_conv $?cc_conv $?fc_conv
echo ec cc and fc_conv $?ec_conv $?cc_conv $?fc_conv    >> $dayfile  

if($?ec_conv && $?cc_conv && $?fc_conv && ($testmsr == '') ) goto stop

if ($iter) goto cycle			#end of sc-cycle

if ( $?f_not_conv ) then
      printf "\n>   FORCES NOT CONVERGED\n"		>> $dayfile    
      printf "\n>   stop\n"			        >> $dayfile
      printf "\n>   FORCES NOT CONVERGED\n"			    
      exit 3
endif
if ( ! $?ec_conv ) then
      printf "\n>   energy in SCF NOT CONVERGED\n"  	>> $dayfile
      printf "\n>   stop\n"			        >> $dayfile
      printf "\n>   energy in SCF NOT CONVERGED\n"  
      exit 0
endif
if ( ! $?cc_conv ) then
      printf "\n>   charge in SCF NOT CONVERGED\n"	>> $dayfile
      printf "\n>   stop\n"			        >> $dayfile
      printf "\n>   charge in SCF NOT CONVERGED\n"
      exit 0
endif

stop:					#normal exit
printf "\n>   stop\n"			>> $dayfile
printf "\n>   stop\n"
exit 0 

stop1:					#normal exit
printf "\n>   stop due to .stop file\n"			>> $dayfile
printf "\n>   stop due to .stop file\n"
if (-e .stop) rm .stop
exit 1 

error_input:					#error exit	
printf "\n>   stop error: the required input file $errin for the next step could not be found\n"		>> $dayfile
printf "\n>   stop error: the required input file $errin for the next step could not be found\n"
exit 9

error:					#error exit	
printf "\n>   stop error\n"		>> $dayfile
printf "\n>   stop error\n"
exit 1

help:					#help exit 
cat << theend 

PROGRAM:	$0

PURPOSE:	running the AFM spinpolarized scf-cycle in WIEN
		to be called within the case-directory
		has to be located in '$WIENROOT' directory

USAGE:		$name [OPTIONS] [FLAGS]

OPTIONS:
-cc LIMIT ->	charge convercence LIMIT ($ccut)
-ec LIMIT ->	energy convercence LIMIT ($ecut Ry)
-fc LIMIT ->	force  convercence LIMIT ($fcut mRy/a.u.)
                default is -ec 0.0001; multiple convergence tests possible
-e PROGRAM ->	exit after PROGRAM ($stopafter)
-i NUMBER -> 	max. NUMBER ($iter) of iterations
-s PROGRAM -> 	start with PROGRAM ($next)
-r NUMBER -> 	restart after NUMBER ($riter) iterations (rm *.broyd*)
-nohns NUMBER ->do not use HNS for NUMBER iterations 
-in1new N ->    use "new" in1 file after N iter (rewrite using scf info)
-ql LIMIT ->    select LIMIT ($qlimit) as min.charge for E-L setting in new in1
 -scratch dir -> set scratch directory (for vector files)
 
FLAGS:
-h/-H ->	help
-I    ->	with initialization of in2-files to "TOT" 
-NI   ->	does NOT delete case.broyd* (default: rm *.broyd* after 60 sec)
-p    ->        run k-points in parallel (needs .machine file [speed:name])
-it   ->        use iterative diagonalization
-it1  ->        use iterative diag. with recreating H_inv (after basis change)
-it2  ->        use iterative diag. with reinitialization (after basis change)
-noHinv   ->    use iterative diag. without H_inv
-vec2pratt ->   use vec2pratt instead of vec2old for iterative diag.
-so   ->	NOT supported in AFM calc
-orb  ->        use LDA+U, OP or B-ext correction
-orbc ->        use LDA+U correction, but with constant V-matrix 
-renorm->       start with mixer and renormalize density
-in1orig->      if present, use case.in1_orig file; do not modify case.in1
-min   ->       force optimization using MSR1a
-eece  ->       on site hybrid (slightly experimental in afm)
		
CONTROL FILES:
.lcore          runs core density superposition producing case.clmsc
.stop		stop after SCF cycle
.fulldiag	force full diagonalization
.noHinv         remove case.storeHinv files
.forceorb       forces to use unmixed case.vorbup/dn files (with -eece)
.forcedmat      forces to use unmixed case.dmatup/dn files (with -orb)
case.inm_vresp  activates calculation of vresp files for meta-GGAs
case.in0_grr    activates a second call of lapw0 (mBJ pot., or E_xc analysis)

ENVIRONMENT VARIBLES:
SCRATCH         directory  where vectors and help files should go

theend

exit 1




More information about the Wien mailing list