# -*-shell-script-*-
#TCL script file created from scripts/work/si_au/si_au_view.script


#*******************************************
# Definition of procedures
#*******************************************

#------------------------------------------------------------
proc readmeam-lammps { } { MD++ {
#Read in MEAM potential (Baskes format)
meamfile = "/home/caiwei/Codes/lammps-15Dec06/examples/meam/meamf"
nspecies = 1  element0 = "Siz" rcut = 6.0  readMEAM
NNM = 300
} }

#-------------------------------------------------------------
proc openwindow { } { MD++ {
# Plot Configuration
#
atomradius = 0.67 bondradius = 0.3 bondlength = 2 #2.8285 #for Si
atomcolor = orange bondcolor = red backgroundcolor = gray70 fixatomcolor = yellow
plotfreq = 100  rotateangles = [ 0 0 0 1.25 ]
openwin  alloccolors rotate saverot eval plot
} }
#end of proc openwindow

#--------------------------------------------
proc exitmd { } { MD++ quit }
#end of proc exitmd

    



#*******************************************
# Main program starts here
#*******************************************
# read in options from command line argument
if { $argc < 1 } {
 set DIRNAME "runs/si-view"
} else { 
 set DIRNAME [lindex $argv 0]
}

if { $argc < 2 } {
 set nstart 1
} else {
 set nstart [lindex $argv 1]
}

if { $argc < 3 } {
 set nend  10
} else {
 set nend [lindex $argv 2]
}

if { $argc < 4 } {
 set nstep 1
} else {
 set nstep [lindex $argv 3]
}

if { $argc < 5 } {
 set tocfg 0
} else {
 set tocfg [lindex $argv 4]
}
puts "dirname = $DIRNAME nstart = $nstart nend = $nend nstep = $nstep tocfg = $tocfg"


MD++ setnolog
MD++ setoverwrite
MD++ dirname = $DIRNAME 

readmeam-lammps

if { $tocfg == 0 } {

 openwindow
 for { set n $nstart} { $n<=$nend } { incr n $nstep } {
    set INCNFILE [format "inter%04d.cn" $n] 
    puts $INCNFILE
    MD++ incnfile = $INCNFILE readcn
    MD++ {input = [0 0 0]} pbcshiftatom
    MD++ eval plot 
    after 1000
 }
 MD++ sleep
} else {
 
 for { set n $nstart} { $n<=$nend } { incr n $nstep } {
    set INCNFILE [format "inter%04d.cn" $n] 
    puts $INCNFILE
    MD++ input = \[ $n $n \] convertCNtoCFG
 }

} 
exitmd
#-------------------------------------------
