Changeset 1140 for branches/sandbox


Ignore:
Timestamp:
Apr 28, 2011 10:46:45 AM (10 years ago)
Author:
lake
Message:

Fixes, macros and other goodies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/rigid.tcl

    r1135 r1140  
    1111# RB_Populate {rb_notebook bodnum args} populates notebook pages with rigid body information
    1212# RB_Map_New {bodnum args}              adds new map for bodnum
     13# RB_VarNums                            determines (add) or removes (sub ##) rigid body variable numbers.
    1314# RB_View_RMS {address args}            prints RMS data from Fit Rigid Body on mapping panel
    1415# RB_Choose_Atom {bodnum args}          finds possible first atom for rigid body mapping
     
    113114}
    114115
    115 
    116116#global variables generated by RB_Load
    117117#
     
    149149                    set ::rb_varcheck($bodnum,$matrixnum) 1
    150150                 }
     151                 puts "in RB_Load_RBdata ::rb_damp = $::rb_damp($bodnum,$matrixnum)"
    151152                 set coords [lindex $temp 3]
    152153                 set ::rb_coord_num($bodnum,$matrixnum) [llength $coords]
     
    294295          grid [label $top.matlbl$matrixnum -text "Matrix $matrixnum"] -row 0 -column [expr $col + 2]
    295296          grid [entry $top.multi$matrixnum -textvariable ::rb_mult($bodnum,$matrixnum) -width 7 -takefocus 1] -row 1 -column [expr $col +2]
     297          puts "in RB_Create_Cart damp = $::rb_damp($bodnum,$matrixnum)"
    296298          grid [entry $top.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 7 -takefocus 1] -row 2 -column  [expr $col +2]
    297299          if {$::rb_mult($bodnum,$matrixnum) == ""} {set ::rb_mult($bodnum,$matrixnum) 1.000}
     
    346348#     puts "cartesian coords:   $temp_car"
    347349     AddRigidBody $temp_mat $temp_car
     350     RecordMacroEntry "AddRigidBody $temp_mat $temp_car" 0
    348351
    349352     incr ::expgui(changed)
     
    375378     foreach phase $::expmap(phaselist) {
    376379             foreach mapnum [RigidBodyMappingList $phase $bodnum] {
    377                      UnMapRigidBody $pphase $bodnum $mapnum
     380                     UnMapRigidBody $phase $bodnum $mapnum
     381                     RecordMacroEntry "UnMapRigidBody $phase $bodnum $mapnum" 0
    378382             }
    379383     }
    380384#    puts "delete rigid body number $bodnum"
    381385     DeleteRigidBody $bodnum
     386     RecordMacroEntry "DeleteRigidBody $bodnum" 0
    382387#    puts "destroy location $location"
    383388     destroy $location
     
    768773#   puts "Euler = $euler"
    769774   MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler
     775   RecordMacroEntry "MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler" 0
    770776   incr ::rb_map($::body_type)
    771777   incr ::expgui(changed)
     
    890896                if {$::rb_unmap($phase,$bodnum,$mapnum) == 1} {
    891897                   UnMapRigidBody $phase $bodnum $mapnum
     898                   RecordMacroEntry "MapRigidBody $::rb_phase $::body_type $::rb_firstatom $origin $euler" 0
    892899                }
    893900        }
     
    932939     grid [label $vm.site -text "sort"] -row 6 -column 0 -columnspan 2
    933940
    934      for {set z 0} {$z < $::rb_coord_num($bodnum,$w)} {incr z} {
    935          grid [checkbutton $vm.sort$z -variable ::rb_sort($z)] -row [expr $z + 7] -column 1
    936          grid [label $vm.lbls$z -text "Site [expr $z+ 1]"] -row [expr $z+7] -column 2
     941     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} {
     942         grid [checkbutton $vm.sort$coordnum -variable ::rb_sort($coordnum)] -row [expr $coordnum + 7] -column 1
     943         grid [label $vm.lbls$coordnum -text "Site [expr $coordnum + 1]"] -row [expr $coordnum + 7] -column 2
    937944     }
    938945     set col 3
    939      for {set i 1} {$i <= $::rb_matrix_num($bodnum)} {incr i} {
    940          grid [label $vm.lblm$i -text "Matrix #$i"] -row 2 -column [expr $col +1]
    941          grid [entry $vm.mult$i -textvariable ::rb_mult($bodnum,$i) -width 8 -takefocus 1] -row 3 -column [expr $col + 1]
    942          grid [entry $vm.damp$i -textvariable ::rb_damp($bodnum,$i) -width 8 -takefocus 1 -state disable] -row 4 -column [expr $col + 1]
    943          grid [checkbutton $vm.var$i -variable ::rb_varcheck($bodnum,$i) -text $::rb_var($bodnum,$i) -state disable -command ""] -row 5 -column [expr $col +1]
    944 
    945          grid [label $vm.x$i -text "X"] -row 6 -column [expr $col]
    946          grid [label $vm.y$i -text "Y"] -row 6 -column [expr $col + 1]
    947          grid [label $vm.z$i -text "Z"] -row 6 -column [expr $col + 2]
    948          for {set j 0} {$j < $::rb_coord_num($bodnum,$w)} {incr j} {
     946     for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     947         grid [label $vm.lblm$matrixnum -text "Matrix #$matrixnum"] -row 2 -column [expr $col +1]
     948         grid [entry $vm.mult$matrixnum -textvariable ::rb_mult($bodnum,$matrixnum) -width 8 -takefocus 1] -row 3 -column [expr $col + 1]
     949         grid [entry $vm.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 8 -takefocus 1 -state normal] -row 4 -column [expr $col + 1]
     950         grid [checkbutton $vm.var$matrixnum -variable ::rb_varcheck($bodnum,$matrixnum) -text $::rb_var($bodnum,$matrixnum) -state normal -command "RB_MMultRef $bodnum $matrixnum"] -row 5 -column [expr $col +1]
     951
     952         grid [label $vm.x$matrixnum -text "X"] -row 6 -column [expr $col]
     953         grid [label $vm.y$matrixnum -text "Y"] -row 6 -column [expr $col + 1]
     954         grid [label $vm.z$matrixnum -text "Z"] -row 6 -column [expr $col + 2]
     955         for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} {
    949956#             puts $::rb_coord($bodnum,$i,$j)
    950957
    951               set ::rb_x($bodnum,$i,$j) [lindex $::rb_coord($bodnum,$i,$j) 0]
    952               set ::rb_y($bodnum,$i,$j) [lindex $::rb_coord($bodnum,$i,$j) 1]
    953               set ::rb_z($bodnum,$i,$j) [lindex $::rb_coord($bodnum,$i,$j) 2]
    954               set ::rb_lbl($bodnum,$i,$j) [lindex $::rb_coord($bodnum,$i,$j) 3]
    955 
    956              grid [entry $vm.lblcx$i$j -textvariable ::rb_x($bodnum,$i,$j) -width 8 -takefocus 1] -row [expr $j+7] -column [expr $col]
    957              grid [entry $vm.lblcy$i$j -textvariable ::rb_y($bodnum,$i,$j) -width 8 -takefocus 1] -row [expr $j+7] -column [expr $col + 1]
    958              grid [entry $vm.lblcz$i$j -textvariable ::rb_z($bodnum,$i,$j) -width 8 -takefocus 1] -row [expr $j+7] -column [expr $col + 2]
    959              grid [label $vm.lblcb$i$j -text "    "] -row [expr  $j+6] -column [expr $col + 3]
     958              set ::rb_x($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0]
     959              set ::rb_y($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 1]
     960              set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 2]
     961              set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3]
     962
     963             grid [entry $vm.lblcx$matrixnum$coordnum -textvariable ::rb_x($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col]
     964             grid [entry $vm.lblcy$matrixnum$coordnum -textvariable ::rb_y($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col + 1]
     965             grid [entry $vm.lblcz$matrixnum$coordnum -textvariable ::rb_z($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col + 2]
     966             grid [label $vm.lblcb$matrixnum$coordnum -text "    "] -row [expr  $coordnum+6] -column [expr $col + 3]
    960967         }
    961968     incr col 4
     
    963970}
    964971
    965 
     972proc RB_VarNums {toggle {var ""} args} {
     973#    initalize rigid body variable list if not already initialized
     974#    toggle can be:
     975#           add      This returns the smallest unused variable number
     976#           sub ##   This removes variable ## from the varlist.
     977
     978     if {[info vars ::rb_varlist] == ""} {
     979        set ::rb_varlist ""
     980     }
     981     if {$::rb_varlist == ""} {
     982          set ::rb_varlist [RigidBodyGetVarNums]
     983     }
     984
     985     if {$toggle == "add"} {
     986          set count 1
     987          while {[lsearch $::rb_varlist $count] > 0} {
     988               incr count
     989          }
     990          lappend ::rb_varlist $count
     991          puts $::rb_varlist
     992          return $count
     993     }
     994     if {$toggle == "sub"} {
     995          set temp ""
     996          foreach v $::rb_varlist {
     997                  if {$v != $var} {
     998                     lappend temp $v
     999                  }
     1000          }
     1001          set ::rb_varlist $temp
     1002          puts $::rb_varlist
     1003          return 0
     1004      }
     1005}
     1006
     1007proc RB_MMultRef {bodnum matrixnum args} {
     1008#    procedure sets or unsets the variable number for the matrix multiplier
     1009     puts "boing:"
     1010     if {$::rb_varcheck($bodnum,$matrixnum) == "0"} {
     1011        set ::rb_var($bodnum,$matrixnum) [RB_VarNums sub $::rb_var($bodnum,$matrixnum)]
     1012     } else {
     1013        set ::rb_var($bodnum,$matrixnum) [RB_VarNums add]
     1014     }
     1015     destroy .viewmatrix
     1016     RB_Edit_Matrix $bodnum
     1017}
    9661018
    9671019proc RB_Sort_Inc {bodnum dir args} {
     
    10321084proc RB_Matrix_Update {bodnum args} {
    10331085     set temp_mat ""
     1086     set temp_damp ""
     1087     set temp_var ""
    10341088     set temp_car ""
    10351089     set temp_mat_group ""
     
    10381092
    10391093     for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     1094         set temp ""
    10401095         lappend temp_mat $::rb_mult($bodnum,$matrixnum)
    1041      }
    1042 
    1043      for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
    1044          set temp ""
     1096         lappend temp_var $::rb_var($bodnum,$matrixnum)
     1097         lappend temp_damp $::rb_damp($bodnum,$matrixnum)
     1098         puts "temp_damp = $::rb_damp($bodnum,$matrixnum)"
    10451099         for {set atomnum 0} {$atomnum < $::::rb_coord_num($bodnum,1)} {incr atomnum} {
    1046                   set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)"
    1047 #                  puts "$temp_cart_triplet $atomnum"
    1048                   lappend temp $temp_cart_triplet
    1049                            }
     1100             set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)"
     1101             lappend temp $temp_cart_triplet
     1102         }
    10501103         lappend temp_car $temp
    10511104     }
     1105
    10521106     puts "Matrix Update Info = $bodnum $temp_mat $temp_car"
    1053      ReplaceRigidBody $bodnum $temp_mat $temp_car
     1107     puts "Matrix damping = $temp_damp"
     1108     puts "Matrix vars = $temp_var"
     1109     SetRigidBodyVar $bodnum $temp_var $temp_damp
     1110     RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0
     1111     ReplaceRigidBody $bodnum $temp_mat $temp_car $temp_var $temp_damp
     1112     RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0
     1113     #SetRigidBodyVar $bodnum $temp_var $temp_damp
    10541114     incr ::expgui(changed)
    10551115     RB_Load_RBdata
     
    11871247   puts "body number = $bodnum"
    11881248   set coordnum 0
    1189    set ::rb_damp($bodnum,1) 0
     1249#   set ::rb_damp($bodnum,1) 0
    11901250   set ::rb_coord_num($bodnum,1) $::gcon_atoms
    11911251
     
    13951455        puts "start atom  = $::gcon_start"
    13961456
    1397 set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list]
    1398 if {[lindex $temp1 0] == {} || [lindex $temp1 1] == {} || [lindex $temp1 2] == {}} {
    1399 #   puts "Geometry Crashed"
    1400    }
    1401 #puts "string 1 = [lindex $temp1 0]"
    1402 #puts "string 2 = [lindex $temp1 1]"
    1403 #puts "string 3 = [lindex $temp1 2]"
    1404 
    1405 set cartesian ""
    1406 lappend cartesian [lindex $temp1 2]
    1407 #puts "Cartesian = $cartesian"
    1408 
    1409 set bodnum [AddRigidBody 1 $cartesian]
    1410 set ::rb_damp($bodnum,1) 0
    1411 set ::rb_coord_num($bodnum,1) $::gcon_atoms
    1412 
    1413 MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1]
    1414 
    1415 destroy .geometry
    1416 
    1417 
    1418 RB_Control_Panel 0
     1457        set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list]
     1458        if {[lindex $temp1 0] == {} || [lindex $temp1 1] == {} || [lindex $temp1 2] == {}} {
     1459           #   puts "Geometry Crashed"
     1460        }
     1461        #puts "string 1 = [lindex $temp1 0]"
     1462        #puts "string 2 = [lindex $temp1 1]"
     1463        #puts "string 3 = [lindex $temp1 2]"
     1464
     1465        set cartesian ""
     1466        lappend cartesian [lindex $temp1 2]
     1467        #puts "Cartesian = $cartesian"
     1468
     1469        set bodnum [AddRigidBody 1 $cartesian]
     1470        # set ::rb_damp($bodnum,1) 0
     1471        set ::rb_coord_num($bodnum,1) $::gcon_atoms
     1472
     1473        MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1]
     1474        RecordMacroEntry "MapRigidBody $::rb_phase $bodnum $::gcon_start [lindex $temp1 0] [lindex $temp1 1]" 0
     1475        destroy .geometry
     1476        RB_Control_Panel 0
    14191477}
    14201478
     
    14321490      grid [frame $con.info -bd 2 -relief groove] -row 1 -column 0 -sticky news
    14331491      grid columnconfig $con 0 -weight 1
    1434       grid [frame $con.con -bd 2 -relief groove] -row 0 -column 0 
     1492      grid [frame $con.con -bd 2 -relief groove] -row 0 -column 0
    14351493      grid [frame $con.terminate -bd 2 -relief groove] -row 2 -column 0
    14361494
    1437 
     1495      #bandaid fix:  load all mapping data
     1496      foreach phase $::expmap(phaselist) {
     1497              foreach bodnum [RigidBodyList] {
     1498                      foreach mapnum [RigidBodyMappingList $phase $bodnum] {
     1499                              RB_Load_Mapdata $phase $bodnum $mapnum
     1500                      }
     1501              }
     1502      }
    14381503
    14391504      #grid rowconfig $con 0 -weight 1
     
    15511616#                             incr col
    15521617                        }
    1553                         grid [label $main.rb_site$phasenum$mapnum$j -text "$atomlist"] -row [expr $row + 1] -column 4 -padx 5 -columnspan 999 -sticky w
     1618                        grid [label $main.rb_site$phasenum$bodnum$mapnum -text "$atomlist"] -row [expr $row + 1] -column 4 -padx 5 -columnspan 999 -sticky w
    15541619                        incr row 2
    15551620                     }
     
    16991764                           $::rb_var($phasenum,$bodnum,$mapnum,e3) 0 0 0"
    17001765                       RigidBodyVary $phasenum $bodnum $mapnum $rb_list
    1701 
     1766                       RecordMacroEntry "incr expgui(changed); RigidBodyVary $phasenum $bodnum $mapnum [list $rb_list]" 0
    17021767                       foreach test $rb_list {
    17031768                            if {$test != 0} {
     
    17201785                           puts "TLS param save for $rb_tls"
    17211786                           RigidBodyTLSVary $phasenum $bodnum $mapnum $rb_tls
    1722 
     1787                           RecordMacroEntry "RigidBodyTLSVary $phasenum $bodnum $mapnum [list $rb_tls]" 0
    17231788                           foreach test $rb_tls {
    17241789                            if {$test != 0} {
     
    17291794                       }
    17301795                       incr ::expgui(changed)
     1796                       #RecordMacroEntry "incr expgui(changed)" 0
    17311797
    17321798               }
     
    17651831
    17661832
    1767 
    1768 
    1769 
    17701833proc RB_Load_Vars {phasenum bodnum mapnum args} {
    17711834     foreach var $::rb_map_positionvars($phasenum,$bodnum,$mapnum) {
     
    17881851             }
    17891852     }
    1790 
    1791 
    17921853
    17931854     set ::rb_var($phasenum,$bodnum,$mapnum,x) [RB_VarSet [lindex $::rb_map_positionvars($phasenum,$bodnum,$mapnum) 0] $mulvarlist]
     
    19802041   grid $vp.refflag.8 -row 6 -column 2
    19812042
    1982 
    1983 
    1984  }
    1985 
     2043}
     2044
Note: See TracChangeset for help on using the changeset viewer.