Changeset 536
- Timestamp:
- Dec 4, 2009 5:07:49 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/addcmds.tcl
- Property rcs:date changed from 2001/12/16 18:08:28 to 2002/01/22 22:10:48
- Property rcs:lines changed from +2 -2 to +82 -99
- Property rcs:rev changed from 1.26 to 1.27
r493 r536 1117 1117 } 1118 1118 1119 proc addatom {phase top} { 1120 global expgui env expmap 1121 set np $top.canvas.fr 1119 # Validate the atoms in the atoms add/phase replace box 1120 # returns a null string on error or a list of atoms 1121 proc ValidateAtomsBox {np} { 1122 1122 set row 0 1123 1123 # loop over the defined rows … … 1149 1149 BK_247 CF CF_249 1150 1150 } 1151 # loop over the defined rows 1151 1152 while {![catch {grid info $np.e[incr row]t}]} { 1152 1153 if !{$expgui(UseAtom$row)} continue … … 1157 1158 } 1158 1159 if {$line == ""} continue 1160 1159 1161 # validate the input 1160 1162 if {[set type [string trim [$np.e${row}t get]]] == ""} { … … 1175 1177 } 1176 1178 lappend atomlist "$type $x $y $z $o $name I $u" 1177 } 1179 } 1178 1180 if {$err != ""} { 1179 1181 MyMessageBox -icon warning -message "Note Errors:\n$err" -parent $top 1180 return 1182 return {} 1181 1183 } 1182 1184 if {[llength $atomlist] == 0} { 1183 1185 MyMessageBox -icon warning -message "No atoms to load!" -parent $top 1184 return 1185 } 1186 return {} 1187 } 1188 return $atomlist 1189 } 1190 1191 proc addatom {phase top} { 1192 global expgui env expmap 1193 set np $top.canvas.fr 1194 # validate the atoms info 1195 set atomlist [ValidateAtomsBox $top $np] 1196 if {$atomslist == ""} return 1197 1186 1198 # ok add the atoms! 1187 1199 set fp [open exptool.in w] … … 1320 1332 -row 6 -column 0 -columnspan 10 -sticky news 1321 1333 set w2 [$w.6 getframe] 1322 grid [label $w2.1 -text "Uiso or Uequiv: "] -row 1 -column 01323 1334 grid [entry $w2.e -width 10] -column 1 -row 1 1324 1335 $w2.e delete 0 end … … 1329 1340 ] -row 2 -column 0 -columnspan 10 1330 1341 grid [frame $w2.f] -row 3 -column 0 -columnspan 10 1331 grid [button $w2.f.iso -text "Set Isotropic" \ 1332 -command "XformAtomsU $phase [list $numberList] iso" \ 1333 ] -row 0 -column 0 1334 grid [button $w2.f.aniso -text "Set Anisotropic" \ 1335 -command "XformAtomsU $phase [list $numberList] aniso" \ 1336 ] -row 0 -column 1 1342 1343 if {[lindex $expmap(phasetype) [expr {$p - 1}]] != 4} { 1344 grid [label $w2.1 -text "Uiso or Uequiv: "] -row 1 -column 0 1345 grid [button $w2.f.iso -text "Set Isotropic" \ 1346 -command "XformAtomsU $phase [list $numberList] iso" \ 1347 ] -row 0 -column 0 1348 grid [button $w2.f.aniso -text "Set Anisotropic" \ 1349 -command "XformAtomsU $phase [list $numberList] aniso" \ 1350 ] -row 0 -column 1 1351 } else { 1352 grid [label $w2.1 -text "Uiso: "] -row 1 -column 0 1353 } 1337 1354 1338 1355 grid rowconfigure $w 5 -minsize 5 1339 grid [TitleFrame $w.8 -bd 6 -relief groove \ 1340 -text "Erase Atom$suffix"] \ 1341 -row 8 -column 0 -columnspan 10 -sticky news 1342 set w2 [$w.8 getframe] 1343 grid [button $w2.do -text "Erase Atom${suffix}" \ 1344 -command "EraseAtoms $phase [list $numberList] $w" \ 1345 ] -row 2 -column 0 -columnspan 10 1346 1356 if {[lindex $expmap(phasetype) [expr {$p - 1}]] != 4} { 1357 grid [TitleFrame $w.8 -bd 6 -relief groove \ 1358 -text "Erase Atom$suffix"] \ 1359 -row 8 -column 0 -columnspan 10 -sticky news 1360 set w2 [$w.8 getframe] 1361 grid [button $w2.do -text "Erase Atom${suffix}" \ 1362 -command "EraseAtoms $phase [list $numberList] $w" \ 1363 ] -row 2 -column 0 -columnspan 10 1364 } 1347 1365 1348 1366 grid rowconfigure $w 9 -minsize 5 … … 1366 1384 # transform the coordinates 1367 1385 proc XformAtomsCoord {phase numberList w1} { 1368 global expgui 1386 global expgui expmap 1387 if {[lindex $expmap(phasetype) [expr {$phase - 1}]] == 4} { 1388 set cmd mmatominfo 1389 } else { 1390 set cmd atominfo 1391 } 1369 1392 # get the matrix 1370 1393 foreach v {x y z} { … … 1376 1399 foreach atom $numberList { 1377 1400 foreach v {x y z} { 1378 set $v [ atominfo$phase $atom $v]1401 set $v [$cmd $phase $atom $v] 1379 1402 } 1380 1403 foreach v {x y z} { … … 1383 1406 set new$v [expr [set new$v] + $matrix(${v}${o})*[set $o]] 1384 1407 } 1385 atominfo$phase $atom $v set [set new$v]1408 $cmd $phase $atom $v set [set new$v] 1386 1409 } 1387 1410 incr expgui(changed) 1388 1411 } 1389 DisplayAllAtoms noreset1412 UpdateAtomLine $numberList $phase 1390 1413 } 1391 1414 1392 1415 # set the occupancies to a single value 1393 1416 proc XformAtomsOcc {phase numberList w2} { 1394 global expgui 1417 global expgui expmap 1418 if {[lindex $expmap(phasetype) [expr {$phase - 1}]] == 4} { 1419 set cmd mmatominfo 1420 } else { 1421 set cmd atominfo 1422 } 1395 1423 # get the value 1396 1424 set val [$w2.e get] 1397 1425 foreach atom $numberList { 1398 atominfo$phase $atom frac set $val1426 $cmd $phase $atom frac set $val 1399 1427 incr expgui(changed) 1400 1428 } 1401 DisplayAllAtoms noreset1429 UpdateAtomLine $numberList $phase 1402 1430 } 1403 1431 … … 1423 1451 set val [$w2.e get] 1424 1452 foreach atom $numberList { 1425 if {[atominfo $phase $atom temptype] == "I"} { 1453 global expmap 1454 if {[lindex $expmap(phasetype) [expr {$phase - 1}]] == 4} { 1455 mmatominfo $phase $atom Uiso set $val 1456 } elseif {[atominfo $phase $atom temptype] == "I"} { 1426 1457 atominfo $phase $atom Uiso set $val 1427 1458 } else { … … 1436 1467 } 1437 1468 } 1438 DisplayAllAtoms noreset1469 UpdateAtomLine $numberList $phase 1439 1470 } 1440 1471 … … 1456 1487 } 1457 1488 mapexp 1458 DisplayAllAtoms 1489 DisplayAllAtoms $phase 1459 1490 destroy $w2 1460 1491 } … … 1503 1534 set file [tk_getOpenFile -parent $top -filetypes $typelist] 1504 1535 if {![file exists $file]} return 1536 # disable during read 1537 catch { 1538 foreach b "$top.b1 $top.b2 $top.fr.b3" { 1539 $b config -state disabled 1540 } 1541 } 1505 1542 # read in the file 1506 1543 set input [$expgui(proc_$format) $file] … … 1518 1555 # sort the atoms by number, so that empty entries are at the bottom 1519 1556 sortAddAtoms $phase $top number 1557 # reenable 1558 catch { 1559 foreach b "$top.b1 $top.b2 $top.fr.b3" { 1560 $b config -state normal 1561 } 1562 } 1520 1563 } 1521 1564 … … 1814 1857 # validate coordinates 1815 1858 set np $top.canvas.fr 1816 set row 0 1817 # loop over the defined rows 1818 set err {} 1819 set atomlist {} 1820 set validatmtypes { 1821 H H-1 H_1 H_2 H_3 HE HE_3 HE_4 LI LI+1 LI_6 LI_7 BE BE+2 B B_10 1822 B_11 C CV C_12 C_13 N N_14 N_15 O O-1 O_16 O_17 O_18 F F-1 F_19 NE 1823 NE_20 NE_21 NE_22 NA NA+1 NA_23 MG MG+2 MG_24 MG_25 MG_26 AL AL+3 1824 AL_27 SI SI+4 SIV SI_28 SI_29 SI_30 P P_31 S S_32 S_33 S_34 CL CL-1 1825 CL_35 CL_37 AR AR_36 AR_40 K K+1 K_39 K_41 CA CA+2 CA_40 CA_44 SC SC+3 1826 SC_45 TI TI+2 TI+3 TI+4 TI_46 TI_47 TI_48 TI_49 TI_50 V V+2 V+3 V+5 1827 V_51 CR CR+2 CR+3 CR_50 CR_52 CR_53 CR_54 MN MN+2 MN+3 MN+4 MN_55 FE 1828 FE+2 FE+3 FE_54 FE_56 FE_57 FE_58 CO CO+2 CO+3 CO_59 NI NI+2 NI+3 1829 NI_58 NI_60 NI_61 NI_62 NI_64 CU CU+1 CU+2 CU_63 CU_65 ZN ZN+2 ZN_64 1830 ZN_66 ZN_67 ZN_68 GA GA+3 GE GE+4 AS AS_75 SE BR BR-1 BR_79 BR_81 KR 1831 RB RB+1 SR SR+2 Y Y+3 Y_89 ZR ZR+4 NB NB+3 NB+5 NB_93 MO MO+3 MO+5 1832 MO+6 TC TC_98 RU RU+3 RU+4 RH RH+3 RH+4 RH_103 PD PD+2 PD+4 AG AG+1 1833 AG+2 CD CD+2 CD_112 CD_113 CD_114 CD_116 IN IN+3 IN_113 IN_115 SN SN+2 1834 SN+4 SB SB+3 SB+5 TE I I-1 I_127 XE CS CS+1 CS_133 BA BA+2 LA LA+3 CE 1835 CE+3 CE+4 PR PR+3 PR+4 PR_141 ND ND+3 PM PM+3 PM_147 SM SM+3 SM_152 1836 SM_154 EU EU+2 EU+3 EU_153 GD GD+3 GD_160 TB TB+3 TB_159 DY DY+3 HO 1837 HO+3 HO_165 ER ER+3 TM TM+3 TM_169 YB YB+2 YB+3 LU LU+3 HF HF+4 TA 1838 TA+5 TA_181 W W+6 RE OS OS+4 IR IR+3 IR+4 PT PT+2 PT+4 AU AU+1 AU+3 1839 AU_197 HG HG+1 HG+2 TL TL+1 TL+3 PB PB+2 PB+4 BI BI+3 BI+5 BI_209 PO 1840 PO_210 AT AT_210 RN RN_222 FR FR_223 RA RA+2 RA_226 AC AC+3 AC_227 TH 1841 TH+4 TH_232 PA PA_231 U U+3 U+4 U+6 U_235 U_238 NP NP+3 NP+4 NP+6 1842 NP_237 PU PU+3 PU+4 PU+6 PU_239 PU_240 PU_242 AM AM_243 CM CM_244 BK 1843 BK_247 CF CF_249 1844 } 1845 while {![catch {grid info $np.e[incr row]t}]} { 1846 if !{$expgui(UseAtom$row)} continue 1847 # ignore blank entries 1848 set line {} 1849 foreach i {t x y z} { 1850 append line [string trim [$np.e${row}$i get]] 1851 } 1852 if {$line == ""} continue 1853 # validate the input 1854 if {[set type [string trim [$np.e${row}t get]]] == ""} { 1855 append err " line $row: No atom type specified\n" 1856 } 1857 if {[lsearch $validatmtypes [string toupper $type]] == -1} { 1858 append err " line $row: Atom type $type is invalid for GSAS\n" 1859 } 1860 set name [string trim [$np.e${row}n get]] 1861 if {$name == "(default)"} {set name "/"} 1862 if {$name == ""} {set name "/"} 1863 foreach i {x y z o u} n {x y z Occ Uiso} { 1864 if {[set $i [string trim [$np.e${row}$i get]]] == ""} { 1865 append err " line $row: No value specified for $n\n" 1866 } elseif {[catch {expr [set $i]}]} { 1867 append err " line $row: The value for $n is invalid\n" 1868 } 1869 } 1870 lappend atomlist "$type $x $y $z $o $name I $u" 1871 } 1872 if {$err != ""} { 1873 MyMessageBox -icon warning -message "Note Errors:\n$err" -parent $top 1874 return 1875 } 1876 if {[llength $atomlist] == 0} { 1877 MyMessageBox -icon warning -message "No atoms to load!" -parent $top 1878 return 1879 } 1859 # validate the atoms info 1860 set atomlist [ValidateAtomsBox $top $np] 1861 if {$atomslist == ""} return 1880 1862 1881 1863 pleasewait "updating phase" … … 1885 1867 phaseinfo $phase $var set $val 1886 1868 } 1869 incr expgui(changed) 1887 1870 # delete all atoms 1888 1871 foreach i $expmap(atomlist_$phase) { 1889 1872 EraseAtom $i $phase 1890 } 1891 incr expgui(changed) 81873 incr expgui(changed) 1874 } 1892 1875 # write new atoms from table as input to exptool 1893 1876 set fp [open exptool.in w] … … 1898 1881 foreach atomline $atomlist { 1899 1882 puts $fp $atomline 1883 incr expgui(changed) 1900 1884 } 1901 1885 close $fp … … 1922 1906 } errmsg 1923 1907 # load the revised exp file 1924 set oldatomlist $expmap(atomlist_$phase)1925 1908 loadexp $expgui(expfile) 1926 1909 set fp [open exptool.out r] … … 1928 1911 close $fp 1929 1912 set err 0 1930 if {[llength $ oldatomlist] == [llength $expmap(atomlist_$phase))]} {1913 if {[llength $atomlist] != [llength $expmap(atomlist_$phase))]} { 1931 1914 set err 1 1932 1915 }
Note: See TracChangeset
for help on using the changeset viewer.