TABLE OF CONTENTS
::pwtk::vecFromTo
SYNOPSIS
proc ::pwtk::vecFromTo {fromUnit toUnit vecs} {
PURPOSE
Transform 3D vectors from one unit to another one. Units can be bohr, angstrom, or a real number interpreted as 'alat'.
ARGUMENTS
- fromUnit -- units in which the input 3D lattice vectors are specified (either bohr, angstrom, or a real number interpreted as 'alat')
- toUnit -- units in which to return the output 3D lattice vectors (either bohr, angstrom, or a real number interpreted as 'alat')
- vecs -- 3D lattice vectors (can be many)
SOURCE
# transform to Bohr switch -glob $fromUnit { bohr { set scale 1.0 } angs* { set scale $::pwtk::angs2bohr } default { if { [string is double -strict $fromUnit] } { # interpreted as alat set scale $fromUnit } else { ::pwtk::error "wrong input unit (aka fromUnit); expected bohr, angstrom, or a real number, but got $fromUnit" } } } set vecs [scaleVec $scale $vecs] # transform to $toUnit switch -glob $toUnit { bohr { set scale 1.0 } angs* { set scale $::pwtk::bohr2angs } default { if { [string is double -strict $toUnit] } { # interpreted as alat set scale [expr 1.0/$toUnit] } else { ::pwtk::error "wrong output unit (aka toUnit); expected bohr, angstrom, or a real number, but got $toUnit" } } } return [scaleVec $scale $vecs] }