source commands.tcl

module PW -title "PWSCF GUI: module PW.x" -script {
    
    readfilter  ::pwscf::pwReadFilter
    writefilter ::pwscf::pwWriteFilter

    # ------------------------------------------------------------------------
    # devide the GUI on pages (each namelist on its own page)
    # ------------------------------------------------------------------------

    ########################################################################
    ##                                                                    ##
    ##                      &CONTROL NAMELIST                             ##
    ##                                                                    ##
    ########################################################################

    page controlPage -name "Control" {
	namelist control -name "CONTROL" {
	    optional {
		#-default  "'PWSCF sample input'"
		var title -label "Job Title (title):"

		var calculation {
		    -label     "Type of calculation (calculation):"
		    -widget    radiobox
		    -textvalue {
			"Self-Consistent-Field  <scf>"
			"Non-selfconsistent calculation  <nscf>"
			"Band structure calculation  <bands>"
			"Ionic relaxation  <relax>"
			"Ionic relaxation with Variable-Cell  <vc-relax>"
			"Molecular dynamics  <md>"
			"Molecular dynamics with Variable-Cell  <vc-md>"
		    }
		    -value {
			'scf'
			'nscf'
			'bands'
			'relax'
			'vc-relax'
			'md'
			'vc-md'
		    }
		    -default "Self-Consistent-Field  <scf>"
		}
		
		var max_seconds {
		    -label    "Maximum CPU time \[in seconds\] (max_seconds):"
		    -validate posint
		}

		var restart_mode {
		    -label    "Restart mode (restart_mode):"
		    -widget   optionmenu
		    -textvalue {
			"from scratch  <from_scratch>"
			"from previous interrupted run  <restart>"
		    }
		    -value {
			'from_scratch'
			'restart'
		    }
		}

		var wf_collect {
		    -label     "Make a single restart file (wf_collect):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		separator -label "--- Directories/Files/Stdout ---"
		
		var outdir {
		    -label     "Temporary directory (outdir):"
		    -widget    entrydirselectquote
		    -validate  string
		}

		var wfcdir {
		    -label     "Temp. directory for files generated by each CPU (wfcdir):"
		    -widget    entrydirselectquote
		    -validate  string
		}

		var pseudo_dir \
		    -label    "Directory containing pseudopotential files (pseudo_dir:)" \
		    -widget   [list entrybutton "Directory ..." "::pwscf::pwSelectPseudoDir $this"] \
		    -validate  string

		var prefix -label "Prefix for I/O filenames (prefix):" -validate  string

		var lkpoint_dir {
		    -label "Store each k-point in its own subdirectory (lkpoint_dir):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var disk_io {
		    -label    "Disk Input/Output (disk_io):"
		    -textvalue {
			high default low minimal none
		    }
		    -value {
			'high' 'default' 'low' 'none'
		    }
		    -widget optionmenu
		}

		var verbosity {
		    -label     "Verbosity of output (verbosity):"
		    -widget    optionmenu
		    -textvalue {
			high
			default
			low
			minimal
		    }
		    -value {
			'high'
			'default'
			'low'
			'minimal'
		    }
		}

		var iprint {
		    -label   "Interval (in SCF iterations) for printing band energies (iprint):"
		    -widget   spinint
		    -validate nonnegint
		}

		separator -label "--- Ionic Minimization ---"

		#-text     "threshold on total energy for ionic minimization"
		var etot_conv_thr {
		    -label    "Convergence energy threshold \[in Ry\] (etot_conv_thr):"
		    -validate fortranposreal
		}

		#-text     "Convergence threshold on forces for ionic minimization"
		var forc_conv_thr {
		    -label    "Convergence force threshold \[in Ry/Bohr\] (forc_conv_thr):"
		    -validate fortranposreal
		}

		separator -label "--- Miscellaneous control parameters ---"
		
		var nstep {
		    -label    "Number of ionic steps (nstep):"
		    -widget   spinint
		    -validate posint
		}

		var tstress {
		    -label    "Calculate stress (tstress):"
		    -widget   radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var tprnfor {
		    -label     "Calculate forces (tprnfor):"
		    -variable  tprnfor
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		
		var dt {
		    -label     "Molecular-Dynamics time step (dt):"
		    -validate  fortranposreal
		}

		var tefield {
		    -label     "Add a sawlike potential to bare ionic potential (tefield):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var dipfield {
		    -label     "Add a dipole correction to bare ionic potential (dipfield):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var lelfield {
		    -label     "Add a homogeneous finite electric field (lelfield):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var nberrycyc {
		    -label "Num. of iterations for lelfield [see help] (nberrycyc):"
		    -validate posint
		}

		var lorbm {
		    -label     "Perform orbital magnetization calculation (lorbm):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		separator -label "--- Berry phase ---"

		var lberry {
		    -label     "Calculate Berry phase (lberry):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		var gdir   {
		    -label    "Direction of the k-point strings (gdir):"
		    -widget   optionmenu
		    -textvalue {
			"along 1st reciprocal vector"
			"along 2nd reciprocal vector"
			"along 3rd reciprocal vector"
		    }
		    -value { 1 2 3 }		
		}
		var nppstr {
		    -label "Num. of k-points along each symmetry-reduced string (nppstr):"
		    -validate posint
		}
	    }
	}
    }
    

    ########################################################################
    ##                                                                    ##
    ##                      &SYSTEM NAMELIST                              ##
    ##                                                                    ##
    ########################################################################

    page systemPage -name "System" {

	# ----------------------------------------------------
	# REQUIRED variables
	# ----------------------------------------------------

	namelist system -name "SYSTEM" {	    
	    required {
		#
		# WARNING: if you change the strings among the possible
		#          ibrav values, then search the "tracevar ibrav"
		#          section in the file pwscf-special.tcl and change
		#          there the strings to match EXACTLY with the 
		#          ones defined here !!!
		#	    
		var ibrav {
		    -label     "Braivas lattice index (ibrav):"
		    -fmt       %d
		    -widget    combobox
		    -textvalue {
			"Free lattice"
			"Cubic P (sc)"
			"Cubic F (fcc)"
			"Cubic I (bcc)"
			"Hexagonal and Trigonal P"
			"Trigonal R, 3fold axis c"
			"Trigonal R, 3fold axis <111>"
			"Tetragonal P (st)"
			"Tetragonal I (bct)"
			"Orthorhombic P"
			"Orthorhombic base-centered(bco)"
			"Orthorhombic face-centered"
			"Orthorhombic body-centered"
			"Monoclinic P, unique axis c"
			"Monoclinic P, unique axis b"
			"Monoclinic base-centered"
			"Triclinic P"
		    }
		    -value {0 1 2 3 4 5 -5 6 7 8 9 10 11 12 -12 13 14}
		}

		group lattice_spec -name "Lattice specification:" -decor normal {
		    auxilvar how_lattice {
			-label     "How to specify lattice:"
			-value     {celldm abc}
			-textvalue {"by celldm()" "by A,B,C,cosAB,cosAC,cosBC"}
			-widget    radiobox
		    }
		    
		    dimension celldm {
			-label "Crystallographic constants (celldm)"
			-validate  fortranreal
			-start 1
			-end   6
		    }
		    
		    group abc {
			packwidgets left
			var A -label "A:" -validate fortranposreal
			var B -label "B:" -validate fortranposreal
			var C -label "C:" -validate fortranposreal
		    }
		    group cosABC {
			packwidgets left
			var cosAB -label "cosAB:" -validate fortranreal		    
			var cosAC -label "cosAC:" -validate fortranreal
			var cosBC -label "cosBC:" -validate fortranreal		    
		    }
		}

		var nat {
		    -label    "Number of atoms in the unit cell (nat):"
		    -fmt       %d
		    -default   1
		    -widget    spinint
		    -validate  posint
		}
		
		var ntyp {
		    -label    "Number of types of atoms in the unit cell (ntyp):"
		    -fmt      %d
		    -default  1
		    -widget   spinint  
		    -validate posint
		}		
		
		var ecutwfc {
		    -label    "Kinetic energy cutoff for WAVEFUNCTION \[in Ry\] (ecutwfc):"
		    -validate fortranposreal
		}

		var ecutrho {
		    -label    "Kinetic energy cutoff for DENSITY \[in Ry\] (ecutrho):"
		    -validate fortranposreal
		}
	    }

	    # ----------------------------------------------------
	    # OPTIONAL variables
	    # ----------------------------------------------------

	    optional {		
		var nosym {
		    -label     "Do not use the symmetry (nosym):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		
		var nosym_evc {
		    -label     "Do not use the symmetry except for the k-points (nosym_evc):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		
		var noinv { 
		    -label     "Disable time reversal symmetry in k-point generation (noinv):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var no_t_rev { 
		    -label     "Disable the symmetry operations that require time reversal (no_t_rev):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var force_symmorphic { 
		    -label     "Force the symmetry group to be symmorphic (force_symmorphic):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var use_all_frac { 
		    -label     "Use all symmetry operations with fractionary translations (use_all_frac):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var nbnd {
		    -label    "Number of electronic states (nbnd):"
		    -widget   spinint
		    -validate posint
		    -fmt      %d
		}

		var tot_charge {
		    -label    "Total system charge (tot_charge):"
		    -validate fortranreal
		    -fmt      %f
		}

		var input_dft -label    "Exchange-correlation functional (input_dft):"

		separator -label "--- Occupations ---"

		var occupations {
		    -label    "Occupation of states (occupations):"
		    -widget   optionmenu
		    -textvalue {
			smearing tetrahedra fixed "read from input"
		    }
		    -value {
			'smearing' 'tetrahedra' 'fixed' 'from_input'
		    }
		}

		var one_atom_occupations {
		    -text  "For isolated atoms only (nat=1)"
		    -label "Order the wavefunctions as the atomic starting wavefunctions (one_atom_occupations):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var starting_spin_angle {
		    -text  "For spin-orbit case when domag=.TRUE."
		    -label "Multiply the initial radial wavefunctions by spin-angle functions (starting_spin_angle):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}

		var degauss {
		    -label    "Gaussian spreading for BZ integration \[in Ry\] (degauss):"
		    -validate fortrannonnegreal
		}

		var smearing {
		    -label    "Type of spreading/smearing (smearing):"
		    -textvalue {
			"first order interpolation in Methfessel-Paxton spreading  <methfessel-paxton>"
			"ordinary Gaussian spreading  <gaussian>"
			"Marzari-Vanderbilt cold smearing  <marzari-vanderbilt>"
			"Fermi-Dirac smearing  <fermi-dirac>"
		    }
		    -value  {
			'methfessel-paxton'
			'gaussian'
			'marzari-vanderbilt'
			'fermi-dirac'
		    }
		    -widget optionmenu
		}

		separator -label "--- Spin polarization ---"

		var nspin {
		    -label     "Perform spin-polarized calculation (nspin):"
		    -textvalue {No Yes "Yes noncollinear"}
		    -value     {1  2  4}
		    -widget    radiobox
		}
		
		group spin_polarization -decor none {
 
		    dimension starting_magnetization {
			-label "Starting magnetization (starting_magnetization):"
			-text  "Specify starting magnetization (between -1 and 1) for each \"magnetic\" species"
			-validate  fortranreal
			-start 1 -end 1
		    }
		    
		    var tot_magnetization {
			-label     "Total magnetization (N el. up-down) (tot_magnetization):"
			-validate  posint
			-widget    spinint
		    }
		}
		
		# insert here ...

		separator -label "--- Noncolinear calculation ---"

		var noncolin {
		    -label     "Perform noncolinear calculation (noncolin):"
		    -textvalue {No Yes}
		    -value     {.false. .true.}
		    -widget    radiobox
		}		

		group noncolin_group {
		    dimension angle1 {
			-label "Starting magnetization direction (angle1) :"
			-text  "Specify starting magnetization direction for each \"magnetic\" species"
			-validate  fortranreal
			-start 1 -end 1
		    }

		    dimension angle2 {
			-label "Starting magnetization direction (angle2):"
			-text  "Specify starting magnetization direction for each \"magnetic\" species"
			-validate  fortranreal
			-start 1 -end 1
		    }

		    var lspinorb {
			-label     "Allow the use of a pseudopotential with spin-orbit (lspinorb):"
			-textvalue {No Yes}
			-value     {.false.  .true.}
			-widget    radiobox
		    }
		}
		
		separator -label "--- Constrained/Fixed magnetization ---"

		group constrained_magnetization_group {
		    
		    var constrained_magnetization {
			-label     "Constrained magnetic calculation (constrained_magnetization):"
			-textvalue {
			    "no constrain  <none>" 
			    "constrain TOTAL magnetization  <total>"
			    "constrain ATOMIC magnetization  <atomic>"
			    "constrain magnetization to \"ATOMIC DIRECTION\"  <atomic direction>"
			    "constrain the direction of total magnetization  <total directioin>"
			}
			-value     {'none' 'total' 'atomic' {'atomic direction'} {'total direction'}}
			-widget    optionmenu
		    }
		    
		    dimension fixed_magnetization {
			-label "Fixed total magnetization"
			-start 1 -end 3
			-validate fortranreal
		    }
		    
#		    dimension B_field {
#			-label "Add a fixed magnetic field (B_field):"
#			-start 1 -end 3
#			-validate fortranreal
#		    }
		    
		    var lambda {
			-label "Lamda parameter for constrained magnetization (lambda):"
			-validate fortranreal
		    }
		    
		    var report {
			-label "Interval (in iterations) for printing atomic magnetic moments (report):"
			-validate posint
		    }
		}

		separator -label "--- Hartree Fock & Hybrid Functionals ---"

		var ecutfock {
		    -label    "Kinetic energy cutoff for exact exchange operator \[in Ry\] (ecutfock):"
		    -validate fortranposreal
		}

		var exx_fraction {
		    -label "Fraction of EXX for hybrid functional calculations (exx_fraction):"
		    -validate fortranreal
		}

		var exxdiv_treatment {
		    -label "Approach for treating Coulomb potential divergencies at small q vectors (exxdiv_treatment):"
		    -widget optionmenu
		    -value {
			'gygi-baldereschi'
			'vcut_spherical'
			'vcut_ws'
			'none'
		    }
		    -textvalue {
			gygi-baldereschi
			vcut_spherical
			vcut_ws
			none
		    }
		}

		var ecutvcut {
		    -label "Reciprocal space cutoff for exxdiv_treatment (ecutvcut):"
		    -validate fortranreal
		}

		var screening_parameter {
		    -label "Screening_parameter for HSE like hybrid functionals (screening_parameter):"
		    -validate fortranreal
		}

		group nqx123 {		    
		    packwidgets left
		    var nqx1 -label "nqx1:" -validate fortranposreal
		    var nqx2 -label "nqx2:" -validate fortranposreal
		    var nqx3 -label "n1x3:" -validate fortranposreal		    
		}

		separator -label "--- LDA + U parameters ---"
	       
		var lda_plus_u {
		    -label     "Perform LDA + U calculation (lda_plus_u):"
		    -textvalue {No Yes}
		    -value     {.false.  .true.}
		    -widget    radiobox
		}
		    
		group hubbard -name Hubbard {
		    var lda_plus_u_kind {
			-label     "type of LDA + U calculation (lda_plus_u_kind):"
			-textvalue {
			    "simplified version of Cococcioni and de Gironcoli" 
			    "rotationally invariant scheme of Liechtenstein et al."
			}
			-value     {0 1}
			-widget    radiobox
		    }

		    dimension Hubbard_U {
			-label     "Hubbarb U (Hubbard_U):"
			-validate  fortranreal
			-start 1 -end 1
		    }
		    
		    dimension Hubbard_J0 {
			-label     "Hubbarb J0 (Hubbard_J0):"
			-validate  fortranreal
			-start 1 -end 1
		    }
		    
		    dimension Hubbard_alpha {
			-label     "Hubbard alpha (Hubbard_alpha):"
			-validate  fortranreal
			-start 1 -end 1
		    }

		    dimension Hubbard_beta {
			-label     "Hubbard beta (Hubbard_beta):"
			-validate  fortranreal
			-start 1 -end 1
		    }

		    # can't input Hubbard_J and starting_ns_eigenvalue

		    var U_projection_type {
			-label  "Type of projector on localized orbital (U_projector_type):"
			-widget optionmenu
			-textvalue {
			    "use atomic wfc's (as they are) to build the projector  <atomic>"
			    "use Lowdin orthogonalized atomic wfc's  <ortho-atomic>"
			    "use Lowdin normalization of atomic wfc  <norm-atomic>"
			    "use the information from file \"prefix\".atwfc  <file>"
			}
			-value {
			    'atomic'
			    'ortho-atomic'
			    'norm-atomic'
			    'file'
			}
		    }		
		}

		separator -label "--- Variable cell parameters ---"

		group vc_md -name VC-MD {		    
		    var ecfixed {
			-label     "ecfixed:"
			-validate  fortranreal
		    }
		    var qcutz {
			-label     "qcutz:"
			-validate  fortranreal
		    }
		    var q2sigma {
			-label     "q2sigma:"
			-validate  fortranreal
		    }
		}	
		
		separator -label "--- Saw-like potential parameters ---"

		group tefield_group -name TeField {
		    var edir {
			-label    "Direction of electric field (edir)"
			-widget   optionmenu
			-textvalue {
			    "along 1st reciprocal vector"
			    "along 2nd reciprocal vector"
			    "along 3rd reciprocal vector"
			}
			-value { 1 2 3 }
		    }
		    
		    var emaxpos {
			-text     "Position of maximum of sawlike potential within the unit cell"
			-label    "Position of maximum (emaxpos):"
			-validate fortranreal
		    }

		    var eopreg {
			-text     "Part of the unit cell where the sawlike potential decreases"
			-label    "Where the sawlike potential decreases (eopreg):"
			-validate fortranreal
		    }

		    var eamp -label "Amplitude of the electric field \[in a.u.\] (eamp):"
		}

		separator -label "--- Low-dimensional calculation ---"

		var assume_isolated {
		    -label "Type of correction for isolated systems (assume_isolated):"
		    -widget    radiobox
		    -textvalue {
			"Makov-Payne <makov-payne>"
			"Martyna-Tuckerman <martyna-tuckerman>"
			"Density Counter Charge <dcc>"
			"Effective Screening Medium <esm>"
                        "No correction <none>"
		    }
		    -value {'makov-payne' 'martyna-tuckerman' 'dcc' 'esm' 'none'}
		}	

		separator -label "--- Effective screening medium ---"
	    
		group ESM {
		    var esm_bc {
			-label "Boundary conditions for ESM (esm_bc):"
			-widget    radiobox
			-textvalue {
			    "vacuum-slab-vacuum (open boundary conditions) <bc1>"
			    "metal-slab-metal (dual electrode configuration) <bc2>"
			    "vacuum-slab-metal <bc3>"
			    "regular periodic calculation (no ESM) <pbc>"
			}
			-value {'bc1' 'bc2' 'bc3' 'pbc'}
		    }	
		    var esm_w {
			-label    "Position offset [in a.u.] of the start of the ESM region (esm_w):"
			-validate fortranreal
		    }
		    var esm_efield {
			-label    "Magnitude of the applied electric field [Ryd/a.u.] (esm_efield):"
			-validate fortranreal
		    }
		    var esm_nfit {
			-label    "Number of z-grid points for the polynomial fit @ cell edge (esm_nfit):"
			-validate posint
		    }		    		    
		}

		separator -label "--- Semi-empirical van der Waals (aka DFT-D) ---"

		group vdW {

		    var vdw_corr {
			-label "Type of Van der Waals correction (vdw_corr):"
			-textvalue {Grimme-D2   XDM   None}
			-value     {'grimme-d2' 'xdm' ''}
			-widget    optionmenu
		    }  

		    group dftdG {
			var london_s6 -label "Global scaling parameter for DFT-D (london_s6):" -validate fortranposreal
			var london_rcut -label "Cutoff radius for dispersion interactions \[in a.u.\] (london_rcut):" -validate fortranposreal
		    }

		    group xdmG {
			var xdm_a1 -label "Damping function parameter a1 (xdm_a1):" -validate fortranreal
			var xdm_a2 -label "Damping function parameter a1 (xdm_a2):" -validate fortranreal
		    }

		    group vdw_obsolete -name "Obsolete vdW variables:" -decor normal {
			
			var london {
			    -label "Compute the semi-empirical dispersion term \[aka DFT-D\] (london):"
			    -textvalue {Yes No}
			    -value     {.true. .false.}
			    -widget    radiobox
			}  
			
			var xdm {
			    -label "Compute the XDM-type dispersion term (xdm):"
			    -textvalue {Yes No}
			    -value     {.true. .false.}
			    -widget    radiobox
			}  
		    }
		}

		separator -label "--- FFT mesh (hard grid) for charge density ---"

		var nr1 -label "nr1:" -validate posint -widget spinint
		var nr2 -label "nr2:" -validate posint -widget spinint
		var nr3 -label "nr3:" -validate posint -widget spinint

		separator -label "--- FFT mesh (soft grid) for wavefunction ---"

		var nr1s -label "nr1s:" -validate posint -widget spinint
		var nr2s -label "nr2s:" -validate posint -widget spinint
		var nr3s -label "nr3s:" -validate posint -widget spinint
	    }
	}
    }

    ########################################################################
    ##                                                                    ##
    ##                      &ELECTRONS NAMELIST                           ##
    ##                                                                    ##
    ########################################################################

    page electronsPage -name "Electrons" {
	namelist electrons -name "ELECTRONS" {
	    optional {
		var electron_maxstep {
		    -label     "Max. \# of iterations in SCF step (electron_maxstep):"
		    -widget    spinint
		    -validate  posint
		    -fmt       %d
		}

		var scf_must_converge {
		    -label     "Stop MD or ionic relaxation if SCF fails to converge (scf_must_converge):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		
		var conv_thr {
		    -label     "Convergence threshold for selfconsistency (conv_thr):"
		    -validate  fortranposreal
		}

		var adaptive_thr {
		    -label     "Use adaptive convergence threshold for EXX (adaptive_thr):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
	       
		group adaptive_thr_group -name "Adaptive convergence threshold setup:" {
		    var conv_thr_init  {
			-label     "Convergence threshold used for the first scf cycle (conv_thr_init):"
			-validate  fortranposreal
		    }		    
		    var conv_thr_multi {
			-label     "Convergence threshold factor for the rest of scf cycles (conv_thr_multi):"
			-validate  fortranposreal
		    }
		}

		var startingpot {
		    -label    "Type of starting potential (startingpot):"
		    -widget   optionmenu
		    -textvalue {
			"from atomic charge superposition  <atomic>"
			{from existing potential "prefix".pot file  <file>}
		    }
		    -value {'atomic' 'file'}
		}

		var startingwfc {
		    -label    "Type of starting wavefunctions (startingwfc):"
		    -widget   optionmenu
		    -textvalue {
			"from superposition of atomic orbitals  <atomic>"
			"from <atomic> + superimposed \"randomization\"  <atomic+random>"
			"from random wavefunctions  <random>"
			"from existing wavefunction file  <file>"
		    }
		    -value {'atomic' 'atomic+random' 'random' 'file'}
		}

		separator -label "--- SCF Mixing ---"

		var mixing_mode {
		    -label     "Mixing mode (mixing_mode):"
		    -textvalue {
			"charge density Broyden mixing  <plain>"
			"charge density Broyden mixing with simple Thomas-Fermi (TF) screening  <TF>"
			"charge density Broyden mixing with local-density-dependent TF screening  <local-TF>"
		    }
		    -value {
			'plain' 
			'TF'    
			'local-TF'
		    }
		    -widget optionmenu
		}

		var mixing_beta {
		    -label    "Mixing factor for self-consistency (mixing_beta):"
		    -validate  fortranposreal
		}

		var mixing_ndim {
		    -label    "Number of iterations used in mixing scheme (mixing_ndim):"
		    -widget   spinint
		    -validate posint
		    -fmt      %d
		}

		var mixing_fixed_ns {
		    -text     "For LDA+U only: ns = atomic density appearing in the Hubbard term"
		    -label    "Number of iterations with fixed ns (mixing_fixed_ns):" 
		    -widget   spinint
		    -validate posint
		    -fmt      %d
		}

		separator -label "--- Diagonalization ---"

		var diagonalization {
		    -label    "Type of diagonalization (diagonalization):"
		    -textvalue {
			"Davidson iterative diagonalization with overlap matrix  <david>"
			"Conjugate-gradient-like band-by-band diagonalization  <cg>"
		    }
		    -value {
			'david'
			'cg'
		    }
		    -widget optionmenu
		}
		
		var diago_thr_init {
		    -label "Convergence threshold for 1st iterative diagonalization (diago_thr_init):"
		    -validate fortranreal
		}

		var diago_full_acc {
		    -label "Diagonalize empty states as precise as occupied states (diago_full_acc):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }
		}
		
		var diago_cg_maxiter {
		    -text     "For CONJUGATE-GRADIENT DIAGONALIZATION only"
		    -label    "Max. \# of iterations (diago_cg_maxiter):"
		    -widget   spinint
		    -validate posint
		    -fmt      %d
		}
		
		separator -label "--- DAVIDSON diagonalization ---"

		var diago_david_ndim {
		    -label    "Dimension of workspace (diago_david_ndim):"
		    -widget   spinint
		    -validate posint
		    -fmt      %d
		}

		separator -label "--- Finite electric field calculation ---"

		var efield {
		    -label    "The intensity of the electric field (efield):"
		    -validate fortranreal
		}

		dimension efield_cart {
		    -label    "Finite electric field in cartesian axis (efield_cart):"
		    -validate fortranreal
		    -start    1
		    -end      3
		}

		separator -label "--- Ultrasoft pseudopotentials ---"
		
		var tqr {
		    -label "Use  real-space algorithm for augmentation charges (tqr):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }		
		}

		separator -label "--- Obsolete variables ---"

		var ortho_para {
		    -text     "OBSOLETE: use command-line option \" -ndiag XX\" instead"
		    -label    "(ortho_para):"
		    -validate integer
		}
	    }    
	}
    }

    ########################################################################
    ##                                                                    ##
    ##                      &IONS NAMELIST                                ##
    ##                                                                    ##
    ########################################################################

    page ionsPage -name "Ions" {	
	namelist ions -name "IONS" {
	    optional {
		# this should be modified as it is CASE dependent		
		var ion_dynamics {
		    -label "Type of ionic dynamics (ion_dynamics):"
		    -widget   optionmenu
		    -textvalue {
			"BFGS quasi-newton method for structural optimization  <bfgs>"
			"damped dynamics (quick-min Verlet) for structural optimization  <damp>"
			"Verlet algorithm for molecular dynamics  <verlet>"
			"over-damped Langevin dynamics  <langevin>"
                        "Beeman algorithm for variable cell damped dynamics  <damp>"
			"Beeman algorithm for variable cell MD  <beeman>"
		    }
		    -value {
			'bfgs' 
			'damp' 
			'verlet'
			'langevin'
                        'damp'
			'beeman'
		    }
		}

		var ion_positions {
		    -label "Which ion positions to use when restarting (ion_positions):"
		    -widget radiobox
		    -textvalue { 
			"from restart file"
			"from standard input"			
		    }
		    -value { 'default' 'from_input' }
		}
                
                var phase_space {
		    -label "Type of phase-space (phase_space):"
                    -textvalue {
			"The standard configuration space  <full>"
			"Coarse-grained phase-space defined by few order parameters  <coarse-grained>"
		    }
		    -value {
			'full' 'coarse-grained'
		    }
		    -widget optionmenu
                }

		var pot_extrapolation {
		    -text "Extrapolation for the potential"
		    -label "Type of extrapolation (pot_extrapolation):"
		    -textvalue {
			"no extrapolation  <none>"
			"extrapolate the potential as a sum of atomic-like orbitals  <atomic>"
			"extrapolate potential with first-order  formula  <first_order>"
			"extrapolate potential with second-order formula  <second_order>"
		    }
		    -value {
			'none' 'atomic' 'first_order' 'second_order'
		    }
		    -widget optionmenu
		}
                
		var wfc_extrapolation {
		    -text "Extrapolation for the wavefunctions"
		    -label "Type of extrapolation (wfc_extrapolation):"
		    -textvalue {
			"no extrapolation  <none>"
			"extrapolate wave-functions with first-order  formula  <first_order>"
			"extrapolate wave-functions with second-order formula  <second_order>"
		    }
		    -value {
			'none' 'first_order' 'second_order'
		    }
		    -widget optionmenu
		}                

		var remove_rigid_rot {
		    -label "Remove the total torque from internal forces (remove_rigid_rot):"
		    -widget    radiobox
		    -textvalue { Yes No }	      
		    -value     { .true. .false. }		
		}

		separator -label "--- Molecular Dynamics ---"

		group md {
		    var ion_temperature {
			-label    "Temperature of ions (ion_temperature):"
			-widget   optionmenu
			-textvalue {
			    "velocity rescaling via tempw&tolp  <rescaling>"
			    "velocity rescaling via tempw&nraise  <rescale-v>"
			    "velocity rescaling via delta_t  <rescale-T>"
			    "reduce ionic temperature via delta_t&nraise  <reduce-T>"
			    "\"soft\" Berendsen velocity rescaling via tempw&nraise  <berendsen>"
			    "use Andersen thermostat via tempw&nraise  <andersen>"
			    "initialize to temperature \"tempw\" and leave uncontrolled <initial>"
			    "not controlled  <not_controlled>"
			}
			-value {
			    'rescaling'
			    'rescale-v'
			    'rescale-T'
			    'reduce-T'
			    'berendsen'
			    'andersen'
			    'initial'
			    'not_controlled'
			}
		    }
		    
		    var tempw {
			-label    "Starting temperature in MD runs (tempw):"
			-validate  fortrannonnegreal
		    }
		    
		    var tolp {
			-label    "Tolerance for velocity rescaling (tolp):"
			-validate fortranreal
		    }
                    
                    var delta_t {
			-label    "Temperature rescaling (delta_t):"
			-validate fortranreal
		    }
                    
                    var nraise {
			-label    "Rescaling interval (nraise):"
			-validate integer
		    }

		    var refold_pos {
			-label "Refolded ions at each step into the supercell (refold_pos):"
			-widget    radiobox
			-textvalue { Yes No }	      
			-value     { .true. .false. }
		    }
		}

		separator -label "--- BFGS Structural Optimization ---"

		var upscale {
		    -text    "Max. reduction factor for conv_thr during structural optimization"
		    -label   "Max. reduction factor (upscale):"
		    -validate  fortranposreal
		}

		group bfgs {
		    var bfgs_ndim {
			-label "Workspace dimension used in the PULAY mixing of the residual vectors:"
			-widget   spinint
			-validate posint
		    }

		    var trust_radius_max {
			-label "Maximum ionic displacement in the structural relaxation (trust_radius_max):"
			-validate fortranposreal
		    }

		    var trust_radius_min {
			-label "Minimum ionic displacement in the structural relaxation (trust_radius_min):"
			-validate fortranposreal
		    }

		    var trust_radius_ini {
			-label "Initial ionic displacement in the structural relaxation (trust_radius_ini):"
			-validate fortranposreal
		    }
		    
		    group w1_w2 -name "Parameters used in line search based on the Wolfe conditions:" -decor normal {
			packwidgets left
			var w_1 -label "w_1:" -validate fortranreal			
			var w_2 -label "w_2:" -validate fortranreal			
		    }
		}		                
	    }
	}
    }


    ########################################################################
    ##                                                                    ##
    ##                      &CELL NAMELIST                                ##
    ##                                                                    ##
    ########################################################################

    page variableCellPage -name "Variable Cell" {

	namelist cell -name "CELL" {
	    var cell_dynamics {
		-label "Type of dynamics for the cell (cell_dynamics):"
		-textvalue {
		    "None  <none>"
		    "Damped (Beeman) dynamics of the Parrinello-Raman extended lagrangian  <damp-pr>"
		    "Damped (Beeman) dynamics of the new Wentzcovitch extended lagrangian  <damp-w>"
		    "BFGS quasi-newton algorithm (ion_dynamics must be 'bfgs' too)  <bfgs>"
		    "(Beeman) dynamics of the Parrinello-Raman extended lagrangian  <pr>"
		    "(Beeman) dynamics of the new Wentzcovitch extended lagrangian  <w>"
		}	    
		-value {
		    'none'
		    'damp-pr'
		    'damp-w'
		    'bfgs'
		    'pr'
		    'w'
		}
		-widget optionmenu
	    }
	    
	    var press {
		-label    "Target pressure \[in KBar\] in a variable-cell MD (press):"
		-validate  fortranreal
	    }
	    
	    var wmass {
		-label    "Ficticious cell mass for variable-cell MD (wmass):"
		-validate  fortranreal

	    }
	    
	    var press_conv_thr {
		-label     "Convergence pressure threshold \[in KBar\] (press_conv_thr):"
		-validate  fortranposreal
	    }
	    
	    var cell_factor {
		-text     "This variable is used in the construction of the pseudopotential tables. It should exceed the maximum linear contraction of the cell during a simulation"
		-label    "Cell factor (cell_factor):"
		-validate  fortranreal
	    }

	    var cell_dofree {
		-label "Which of the cell parameters should be moved (cell_dofree):"
		-textvalue {
		    "all     = all axis and angles are propagated"
		    "x       = only the x axis is moved"
		    "y       = only the y axis is moved"
		    "z       = only the z axis is moved"
		    "xy      = only the x and y axis are moved, angles are unchanged"
		    "xz      = only the x and z axis are moved, angles are unchanged"
		    "yz      = only the y and z axis are moved, angles are unchanged"
		    "xyz     = x, y and z axis are moved, angles are unchanged"
		    "shape   = all axis and angles, keeping the volume fixed"
		}	    
		-value {
		    'all' 'x' 'y' 'z' 'xy' 'xz' 'yz' 'xyz' 'shape'  
		}
		-widget optionmenu
	    }
	}
    }


    ########################################################################
    ##                                                                    ##
    ##     CARDS: CELL_PARAMETERS, ATOMIC_SPECIES, ATOMIC_POSITIONS       ##
    ##                                                                    ##
    ########################################################################

    page latticeAtomdataPage -name "Lattice & Atoms" {

	#
	# CELL_PARAMETERS
	#
	group cards__CELL_PARAMETERS -name "Card: CELL_PARAMETERS" -decor normal {
	    line lattice_type_line -decor none {
		keyword cell_parameters CELL_PARAMETERS
		var CELL_PARAMETERS_flags {
		    -label    "Cell parameter's unit:" 
		    -value    {alat bohr angstrom}
		    -textvalue {Alat Bohr Angstrom}
		    -widget   radiobox
		}
	    }
	    table lattice {
		-caption  "Lattice Basis Vectors:"
		-head     {X-Component Y-Component Z-Component}
		-validate {fortranreal fortranreal fortranreal}
		-cols     3
		-rows     3
		-outfmt   {"  %14.9f" %14.9f %14.9f}
	    }	
	}

	#
	# ATOMIC_SPECIES
	#
	group atomic_species_group -name "Card: ATOMIC_SPECIES" -decor normal {
	    keyword atomic_species_key ATOMIC_SPECIES\n
	    table atomic_species \
		-caption  "Atomic types:" \
		-head     {Atomic-label Atomic-Mass Pseudopotential-file} \
		-cols     3 \
		-rows     1 \
		-outfmt   {"  %3s" %10.5f " %s"} \
		-validate {whatever fortranreal whatever} \
		-widgets  [list entry entry [list entrybutton "Pseudopotential ..." [list ::pwscf::pwSelectPseudopotential $this atomic_species]]]	    
	}

	#
	# ATOMIC_POSITIONS
	#

	group atomic_positions_group -name "Card: ATOMIC_POSITIONS" -decor normal {
	    line atom_coor_unit -decor none {
		keyword atomic_positions ATOMIC_POSITIONS
		var ATOMIC_POSITIONS_flags {
		    -label    "Atomic coordinate length unit:" 
		    -textvalue {
			"Cartesian in ALAT (i.e. in length units of celldm(1))  <alat>"
			"Cartesian in BOHR  <bohr>"
			"Cartesian in ANGSTROMS  <angstroms>"
			"Internal crystal coordinates  <crystal>"
		    }
		    -value {alat bohr angstrom crystal}	    
		    -widget radiobox
		    -default "Cartesian in ALAT (i.e. in length units of celldm(1))  <alat>"
		}
	    }
		
	    table atomic_coordinates {
		-caption   "Atomic coordinates:"
		-head      {Atomic-label X-Coordinate Y-Coordinate Z-Coordinate if_pos(1) if_pos(2) if_pos(3)}
		-validate  {string fortranreal fortranreal fortranreal binary binary binary}
		-cols      7
		-rows      1
		-outfmt    {"  %3s" "  %14.9f" %14.9f %14.9f "  %2d" %2d %2d}
		-widgets   {entry entry entry entry checkbutton}
		-onvalues  1
		-offvalues 0
		-optionalcols 4
	    }
	    # -optcols   {4 5 6}

	    loaddata atomic_coordinates ::pwscf::pwLoadAtomCoor \
		"Load atomic coordinates from file ..."    
	}
    }


    ########################################################################
    ##                                                                    ##
    ##                         CARD: K_POINTS                             ##
    ##                                                                    ##
    ########################################################################

    page kpointsPage -name "K-points" {
	#
	# K_POINTS
	#
	group k_points_group -name "Card: K_POINTS" -decor normal {
	    line kpoint_type_line -decor none {
		keyword k_points K_POINTS
		var K_POINTS_flags {
		    -label    "K-points type:" 
		    -textvalue {
			"Manual specification in 2pi/a units  <tpiba>"
			"Manual specification in CRYSTAL units  <crystal>"
			"Automatic generation  <automatic>"
			"Gamma point only  <gamma>"
			"Manual \"2pi/a\" specification for band structure plot <tpiba_b>"
			"Manual \"crystal\" specification for band structure plot <crystal_b>"
		    }
		    -value {
			tpiba crystal automatic gamma tpiba_b crystal_b
		    }
		    -widget radiobox
		    -default "Manual specification in 2pi/a units  <tpiba>"
		}
	    }
	    
	    line nks_line -decor none {
		var nks -label "Number of K-points:" -widget spinint -validate posint -default 1
	    }

	    # if nks=0 then enter the mesh and shifts
	    group kmesh_shift_group -name "k-points mesh + shift" -decor normal {
		line kmesh_line -decor none {
		    group kmesh -name Kmesh {
			packwidgets left
			var nk1 -label "nk1:"  -widget spinint  -validate posint  -outfmt "  %d "  -default 1
			var nk2 -label "nk2:"  -widget spinint  -validate posint  -outfmt "%d "  -default 1
			var nk3 -label "nk3:"  -widget spinint  -validate posint  -outfmt "%d "  -default 1
		    }
		    group kshift -name Kshift {
			packwidgets left
			var sk1 -label "sk1:"  -widget spinint  -validate binary  -outfmt "  %d "  -default 1
			var sk2 -label "sk2:"  -widget spinint  -validate binary  -outfmt "%d "  -default 1
			var sk3 -label "sk3:"  -widget spinint  -validate binary  -outfmt "%d "  -default 1
		    }
		}
	    }

	    # elseif nks>0 enetr kpoint coordinates
	    table kpoints {
		-caption  "Enter the coordinates of the K-points below:"
		-head     {KX-Coordinate KY-Coordinate KZ-Coordinate Weight}
		-cols     4
		-rows     0
		-validate {fortranreal fortranreal fortranreal fortranreal}
		-outfmt   {%14.9f %14.9f %14.9f "  %14.9f"}
	    }
	    loaddata kpoints ::pwscf::pwLoadKPoints \
		"Load K-point coordinates from file ..."	
	}
    }

    ########################################################################
    ##                                                                    ##
    ##         PAGE: CONSTRAINTS & OCCUPATIONS          ##
    ##                                                                    ##
    ########################################################################
    page otherPage -name "Other Cards" {

	# CARD: CONSTRAINTS
	
	group constraints_group -name "Card: CONSTRAINTS" -decor normal {

	    auxilvar constraints_enable {
		-label     "Use constraints:"
		-value     {Yes No}
		-widget    radiobox
		-default   No
	    }

	    group constraints_card -decor none {

		keyword constraints_key CONSTRAINTS\n

		line constraints_line1 -decor none {
		    var nconstr {
			-label    "Number of constraints:"		    
			-validate posint
			-widget   spinint
			-default  1
			-outfmt   "  %d "
		    }
		    var constr_tol {
			-label    "Tolerance for keeping the constraints satisfied:"
			-validate fortranposreal
		    }
		}

		table constraints_table {
		    -caption  "Enter constraints data:\n    constraint-type   constr(1,.)   constr(2,.)   ...   { constr_target(.) }\n\n(see Help for the format of \"constraint-specification\")"
		    -head     {constraint-type constraint-specifications ... ... ... ...}
		    -validate {string fortranreal}
		    -cols     6
		    -rows     1
		    -optionalcols 3
		    -widgets  {{optionmenu {'type_coord' 'atom_coord' 'distance' 'planar_angle' 'torsional_angle' 'bennett_proj'}} entry}
		    -outfmt   {"  %s  " %S}
		    -infmt    {%d %S}
		}
	    }
	}    

	# CARD: OCCUPATIONS
	
	group occupations_card -name "Card: OCCUPATIONS" -decor normal {	    
	    keyword occupations_key OCCUPATIONS\n
	    text occupations_table \
		-caption "Syntax for NON-spin polarized case:\n     u(1)  ....   ....   ....  u(10)\n     u(11) .... u(nbnd)\n\nSyntax for spin-polarized case:\n     u(1)  ....   ....   ....  u(10)\n     u(11) .... u(nbnd)\n     d(1)   ....  ....   ....  d(10)\n     d(11) .... d(nbnd)" \
		-label   "Specify occupation of each state (from 1 to nbnd) such that 10 occupations per are written per line:" \
		-readvar ::pwscf::pwscf($this,OCCUPATIONS)
	}
    }
    

    # ----------------------------------------------------------------------
    # take care of specialities
    # ----------------------------------------------------------------------
    source pw-event.tcl

    # ------------------------------------------------------------------------
    # source the HELP file
    # ------------------------------------------------------------------------
    source pw-help.tcl
}
