Changeset 1145 for branches/sandbox


Ignore:
Timestamp:
Jun 23, 2011 4:59:25 PM (9 years ago)
Author:
lake
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/rigid.tcl

    r1140 r1145  
    149149                    set ::rb_varcheck($bodnum,$matrixnum) 1
    150150                 }
    151                  puts "in RB_Load_RBdata ::rb_damp = $::rb_damp($bodnum,$matrixnum)"
     151#                 puts "in RB_Load_RBdata ::rb_damp = $::rb_damp($bodnum,$matrixnum)"
    152152                 set coords [lindex $temp 3]
    153153                 set ::rb_coord_num($bodnum,$matrixnum) [llength $coords]
     
    159159                     set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0]
    160160                     set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 0]
     161#                    restore values                     
     162                     set ::rb_matrix_num_temp($bodnum) $::rb_matrix_num($bodnum)
     163                     set ::rb_coord_num_temp($bodnum,1) $::rb_coord_num($bodnum,1)
     164                     set ::rb_coord_temp($bodnum,$matrixnum,$coordnum) $::rb_coord($bodnum,$matrixnum,$coordnum)
     165
    161166                 }
    162167             }
     
    291296     set col 0
    292297     grid [label $top.multilbl -text "Matrix Multiplier"] -row 1 -column 0
    293      grid [label $top.damplbl -text "Damping Factor"] -row 2 -column 0
     298#     grid [label $top.damplbl -text "Damping Factor"] -row 2 -column 0
    294299     for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
    295300          grid [label $top.matlbl$matrixnum -text "Matrix $matrixnum"] -row 0 -column [expr $col + 2]
    296301          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)"
    298           grid [entry $top.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 7 -takefocus 1] -row 2 -column  [expr $col +2]
     302#          puts "in RB_Create_Cart damp = $::rb_damp($bodnum,$matrixnum)"
     303
     304#          set dampfactors "0 1 2 3 4 5 6 7 8 9"
     305#          eval tk_optionMenu $top.damp$matrixnum ::rb_damp($bodnum,$matrixnum) $dampfactors
     306#          grid $top.damp$matrixnum -row 2 -column [expr $col +2]
     307#          $top.damp$matrixnum config -width 4
     308
     309
     310#          grid [entry $top.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 7 -takefocus 1] -row 2 -column  [expr $col +2]
     311
     312
    299313          if {$::rb_mult($bodnum,$matrixnum) == ""} {set ::rb_mult($bodnum,$matrixnum) 1.000}
    300           if {$::rb_damp($bodnum,$matrixnum) == ""} {set ::rb_damp($bodnum,$matrixnum) 0}
     314#          if {$::rb_damp($bodnum,$matrixnum) == ""} {set ::rb_damp($bodnum,$matrixnum) 0}
    301315
    302316          grid [label $main.x$matrixnum -text "X"] -row 0 -column [expr $col + 1]
     
    701715    set ::rb_atom_rms ""
    702716    foreach atom $atoms rms $rmsbyatom {
    703         puts "[atominfo $phase $atom label]\t$rms"
     717#       puts "[atominfo $phase $atom label]\t$rms"
    704718        lappend ::rb_atom_rms "[atominfo $phase $atom label] $rms"
    705719    }
     
    907921}
    908922
     923proc RB_Create_from_Edit {args} {
     924     set bodnum [RB_New_RBnum]
     925     RB_Create_Save $bodnum
     926}
     927
     928
    909929
    910930proc RB_Edit_Matrix {bodnum args} {
    911      puts "Bodnum = $bodnum"
     931#     puts "Bodnum = $bodnum"
    912932     catch {destroy .viewmatrix}
    913933     set em .viewmatrix
     
    920940     set sm $em.sort
    921941     grid [frame $vm -bd 2 -relief groove] -row 0 -column 0 -columnspan 2
    922      grid [frame $um -bd 2 -relief groove] -row 1 -column 1
    923      grid [frame $sm -bd 2 -relief groove] -row 1 -column 0
    924 
    925      grid [label $sm.sort -text "Sort Matrix"] -row 1 -column 0 -columnspan 2
    926      grid [button $sm.inc -text "\u2191" -command "RB_Sort_Inc $bodnum inc"] -row 2 -column 0
    927      grid [button $sm.dec -text "\u2193" -command "RB_Sort_Inc $bodnum dec"] -row 2 -column 1
    928 
    929      grid [button $um.update -text "Update Matrix Info" -bg green -command "RB_Matrix_Update $bodnum"] -row 0 -column 0 -padx 5
     942     grid [frame $sm -bd 2 -relief groove] -row 1 -column 0 -columnspan 2 -pady 10
     943     grid [frame $um -bd 2 -relief groove] -row 2 -column 0 -columnspan 2
     944
     945#    Editor Options
     946     grid [label $sm.title -text "Matrix Editor Control Panel"] -row 0 -column 0 -columnspan 4
     947     grid [label $sm.sort -width 21 -text "Move Checked Elements"] -row 1 -column 0
     948     grid [button $sm.inc -text "\u2191" -command "RB_Sort_Inc $bodnum inc"] -row 1 -column 1 -padx 5
     949     grid [button $sm.dec -text "\u2193" -command "RB_Sort_Inc $bodnum dec"] -row 1 -column 2 -padx 5
     950     grid [button $sm.swap -width 21 -text "Swap Checked Elements" -command "RB_Sort_Swap $bodnum"] -row 2 -column 0 -columnspan 3
     951     grid [button $sm.delete -width 21 -text "Delete Checked Elements" -command "RB_Delete_Element $bodnum"] -row 3 -column 0 -columnspan 3
     952     grid [button $sm.add   -width 21 -text "Add New Matrix Elements" -command "RB_Add_Element $bodnum"] -row 4 -column 0 -columnspan 3
     953     grid [button $sm.addmatrix -width 21 -text "Add New Matrix" -command "RB_Add_New_Matrix $bodnum"] -row 5 -column 0 -columnspan 3
     954
     955#    Save Options
     956     grid [button $um.update -width 24 -text "Update Matrix Info" -bg green -command "RB_Matrix_Update $bodnum"] -row 3 -column 0 -padx 5
     957     grid [button $um.new -width 24 -text "New Rigid Body Type" -command "RB_Create_from_Edit"] -row 0 -column 1 -padx 5
    930958 #    grid [button $um.sort -text "Sort Matrix Info" -command "RB_Cart_Sort $bodnum"] -row 0 -column 1
    931      grid [button $um.abort -text "Abort" -width 18 -command "destroy $em"] -row 0 -column 2 -padx 5
    932      grid [button $um.print -text "Save Cartesian \n Coordinates to File" -command "RB_CartesianTextFile $bodnum"] -row 1 -column 0 -pady 5
     959
     960     grid [button $um.print -width 24 -text "Save Cartesian \n Coordinates to File" -command "RB_CartesianTextFile $bodnum"] -row 2 -column 1 -pady 5
     961     grid [button $um.restore -width 24 -text "Restore Original Matrix" -command "RB_Restore_Matrix $bodnum"] -row 3 -column 1 -padx 5
     962     grid [button $um.abort -text "Abort" -width 24 -command "RB_Edit_Matrix_Abort $bodnum $em"] -row 3 -column 2 -padx 5
    933963
    934964     grid [label $vm.lblmm -text "Matrix Multiplier"] -row 3 -column 2
     
    938968     set w 1
    939969     grid [label $vm.site -text "sort"] -row 6 -column 0 -columnspan 2
     970
    940971
    941972     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,$w)} {incr coordnum} {
     
    947978         grid [label $vm.lblm$matrixnum -text "Matrix #$matrixnum"] -row 2 -column [expr $col +1]
    948979         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]
     980         set dampfactors "0 1 2 3 4 5 6 7 8 9"
     981         eval tk_optionMenu $vm.damp$matrixnum ::rb_damp($bodnum,$matrixnum) $dampfactors
     982         grid $vm.damp$matrixnum -row 4 -column [expr $col + 1]
     983         $vm.damp$matrixnum config -width 4
     984#         grid [entry $vm.damp$matrixnum -textvariable ::rb_damp($bodnum,$matrixnum) -width 8 -takefocus 1 -state normal] -row 4 -column [expr $col + 1]
     985         grid [checkbutton $vm.var$matrixnum -variable ::rb_varcheck($bodnum,$matrixnum) -text $::rb_var($bodnum,$matrixnum) \
     986              -state normal -command "RB_MMultRef $bodnum $matrixnum"] -row 5 -column [expr $col +1]
    951987
    952988         grid [label $vm.x$matrixnum -text "X"] -row 6 -column [expr $col]
     
    960996              set ::rb_z($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 2]
    961997              set ::rb_lbl($bodnum,$matrixnum,$coordnum) [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3]
     998
    962999
    9631000             grid [entry $vm.lblcx$matrixnum$coordnum -textvariable ::rb_x($bodnum,$matrixnum,$coordnum) -width 8 -takefocus 1] -row [expr $coordnum+7] -column [expr $col]
     
    9701007}
    9711008
     1009proc RB_Restore_Matrix {bodnum} {
     1010     set ::rb_matrix_num($bodnum) $::rb_matrix_num_temp($bodnum)
     1011     set ::rb_coord_num($bodnum,1) $::rb_coord_num_temp($bodnum,1)
     1012         for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} {
     1013             for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     1014                 set ::rb_coord($bodnum,$matrixnum,$coordnum) $::rb_coord_temp($bodnum,$matrixnum,$coordnum)
     1015
     1016             }
     1017     }
     1018RB_Edit_Matrix $bodnum
     1019}
     1020
     1021proc RB_Add_New_Matrix {bodnum} {
     1022     incr ::rb_matrix_num($bodnum)
     1023     set matrixnum $::rb_matrix_num($bodnum)
     1024     set ::rb_var($bodnum,$matrixnum) 0
     1025     set ::rb_mult($bodnum,$matrixnum) 1.000
     1026     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} {
     1027         set ::rb_coord($bodnum,$matrixnum,$::rb_coord_num($bodnum,1) ""
     1028         lappend ::rb_coord($bodnum,$matrixnum,$coordnum) 0 0 0 lbl
     1029     }
     1030     RB_Edit_Matrix $bodnum
     1031
     1032
     1033}
     1034
     1035
     1036
     1037proc RB_Edit_Matrix_Abort {bodnum location} {
     1038#    reset matrix
     1039#     set ::rb_coord_num($bodnum,1) $::rb_coord_num_temp($bodnum,1)
     1040#     for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     1041#         for {set coordnum 0} {$coordnum < $::rb_coord_num_temp($bodnum,1)} {incr coordnum} {
     1042#             set ::rb_coord($bodnum,$matrixnum,$coordnum) $::rb_coord_temp($bodnum,$matrixnum,$coordnum)
     1043#         }
     1044#     }
     1045     destroy $location
     1046}
     1047
     1048proc RB_Add_Element {bodnum} {
     1049     incr ::rb_coord_num($bodnum,1)
     1050     for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     1051         set ::rb_coord($bodnum,$matrixnum,$::rb_coord_num($bodnum,1) ""
     1052         lappend ::rb_coord($bodnum,$matrixnum,[expr $::rb_coord_num($bodnum,1)- 1]) 0 0 0 lbl
     1053         puts $::rb_coord($bodnum,$matrixnum,[expr $::rb_coord_num($bodnum,1) - 1])
     1054     }
     1055
     1056}
     1057
     1058proc RB_Delete_Element {bodnum} {
     1059
     1060     set newcoord 0
     1061     set deletedrecords 0
     1062
     1063     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} {
     1064           for {set matrixnum 1} {$matrixnum <= $::rb_matrix_num($bodnum)} {incr matrixnum} {
     1065
     1066               if {$::rb_sort($coordnum) != 1} {
     1067                  set xtemp $::rb_x($bodnum,$matrixnum,$coordnum)
     1068                  set ytemp $::rb_y($bodnum,$matrixnum,$coordnum)
     1069                  set ztemp $::rb_z($bodnum,$matrixnum,$coordnum)
     1070                  set lbltemp [lindex $::rb_coord($bodnum,$matrixnum,$coordnum) 3]
     1071
     1072
     1073                  set ::rb_x($bodnum,$matrixnum,$newcoord) $xtemp
     1074                  set ::rb_y($bodnum,$matrixnum,$newcoord) $ytemp
     1075                  set ::rb_z($bodnum,$matrixnum,$newcoord) $ztemp
     1076                  puts "array element = $::rb_coord($bodnum,$matrixnum,$coordnum)"
     1077                  set ::rb_coord($bodnum,$matrixnum,$newcoord) ""
     1078                  puts "xyztemp = $xtemp $ytemp $ztemp $lbltemp"
     1079                  lappend ::rb_coord($bodnum,$matrixnum,$newcoord) $xtemp $ytemp $ztemp $lbltemp
     1080                  puts "goofy output = $::rb_coord($bodnum,$matrixnum,$newcoord)"
     1081                  incr newcoord
     1082               } else {
     1083                  incr deletedrecords
     1084               }
     1085           }
     1086     }
     1087     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} {
     1088         set ::rb_sort($coordnum) 0
     1089     }
     1090     set tempcoord [expr $::rb_coord_num($bodnum,1) - $deletedrecords]
     1091     set ::rb_coord_num($bodnum,1) $tempcoord
     1092     RB_Edit_Matrix $bodnum
     1093}
     1094
     1095
     1096
    9721097proc RB_VarNums {toggle {var ""} args} {
    9731098#    initalize rigid body variable list if not already initialized
     
    9891114          }
    9901115          lappend ::rb_varlist $count
    991           puts $::rb_varlist
     1116#          puts $::rb_varlist
    9921117          return $count
    9931118     }
     
    10001125          }
    10011126          set ::rb_varlist $temp
    1002           puts $::rb_varlist
     1127#          puts $::rb_varlist
    10031128          return 0
    10041129      }
     
    10071132proc RB_MMultRef {bodnum matrixnum args} {
    10081133#    procedure sets or unsets the variable number for the matrix multiplier
    1009      puts "boing:"
     1134#     puts "boing:"
    10101135     if {$::rb_varcheck($bodnum,$matrixnum) == "0"} {
    10111136        set ::rb_var($bodnum,$matrixnum) [RB_VarNums sub $::rb_var($bodnum,$matrixnum)]
     
    10151140     destroy .viewmatrix
    10161141     RB_Edit_Matrix $bodnum
     1142}
     1143
     1144proc RB_Sort_Swap {bodnum args} {
     1145     set count 0
     1146     set rb_swap_list ""
     1147     for {set coordnum 0} {$coordnum < $::rb_coord_num($bodnum,1)} {incr coordnum} {
     1148         if {$::rb_sort($coordnum) == 1} {
     1149            incr count
     1150            lappend rb_swap_list $coordnum
     1151         }
     1152     }
     1153     if {$count != 2} {
     1154#        puts "wrong number of arguments, swap failed"
     1155        bell
     1156        return
     1157     }
     1158#     puts "swap happens"
     1159#     puts $rb_swap_list
     1160     for {set i 1} {$i <= $::rb_matrix_num($bodnum)} {incr i} {
     1161         set coord1 [lindex $rb_swap_list 0]
     1162         set coord2 [lindex $rb_swap_list 1]
     1163         set x1dum $::rb_x($bodnum,$i,$coord1)
     1164         set y1dum $::rb_y($bodnum,$i,$coord1)
     1165         set z1dum $::rb_z($bodnum,$i,$coord1)
     1166         set ::rb_x($bodnum,$i,$coord1) $::rb_x($bodnum,$i,$coord2)
     1167         set ::rb_y($bodnum,$i,$coord1) $::rb_y($bodnum,$i,$coord2)
     1168         set ::rb_z($bodnum,$i,$coord1) $::rb_z($bodnum,$i,$coord2)
     1169         set ::rb_x($bodnum,$i,$coord2) $x1dum
     1170         set ::rb_y($bodnum,$i,$coord2) $y1dum
     1171         set ::rb_z($bodnum,$i,$coord2) $z1dum
     1172     }
     1173
    10171174}
    10181175
     
    10241181         }
    10251182     }
    1026      puts $sortlist
     1183#     puts $sortlist
    10271184
    10281185     foreach check $sortlist {
     
    10711228
    10721229proc RB_String_Reverse {string args} {
    1073     puts "$string"
     1230#    puts "$string"
    10741231    set rstring ""
    10751232    set len [expr [llength $string] - 1]
     
    10781235        incr len -1
    10791236    }
    1080     puts "contents of rstring = $rstring"
     1237#    puts "contents of rstring = $rstring"
    10811238    return $rstring
    10821239}
     
    10961253         lappend temp_var $::rb_var($bodnum,$matrixnum)
    10971254         lappend temp_damp $::rb_damp($bodnum,$matrixnum)
    1098          puts "temp_damp = $::rb_damp($bodnum,$matrixnum)"
     1255#         puts "temp_damp = $::rb_damp($bodnum,$matrixnum)"
    10991256         for {set atomnum 0} {$atomnum < $::::rb_coord_num($bodnum,1)} {incr atomnum} {
    11001257             set temp_cart_triplet "$::rb_x($bodnum,$matrixnum,$atomnum) $::rb_y($bodnum,$matrixnum,$atomnum) $::rb_z($bodnum,$matrixnum,$atomnum)"
     
    11041261     }
    11051262
    1106      puts "Matrix Update Info = $bodnum $temp_mat $temp_car"
    1107      puts "Matrix damping = $temp_damp"
    1108      puts "Matrix vars = $temp_var"
     1263#     puts "Matrix Update Info = $bodnum $temp_mat $temp_car"
     1264#     puts "Matrix damping = $temp_damp"
     1265#     puts "Matrix vars = $temp_var"
    11091266     SetRigidBodyVar $bodnum $temp_var $temp_damp
    11101267     RecordMacroEntry "SetRigidBodyVar $bodnum $temp_var $temp_damp" 0
     
    12421399   set coordlist ""
    12431400   lappend coordlist [lindex $temp1 2]
    1244    puts $coordlist
     1401#   puts $coordlist
    12451402
    12461403   set bodnum [RB_New_RBnum]
    1247    puts "body number = $bodnum"
     1404#   puts "body number = $bodnum"
    12481405   set coordnum 0
    12491406#   set ::rb_damp($bodnum,1) 0
     
    14491606                }
    14501607        }
    1451         puts "Origin list = $::gcon_origin_list"
    1452         puts "vector 1 list = $vector1list"
    1453         puts "vector 2 list = $vector2list"
    1454         puts "number atoms = $::gcon_atoms"
    1455         puts "start atom  = $::gcon_start"
     1608#        puts "Origin list = $::gcon_origin_list"
     1609#        puts "vector 1 list = $vector1list"
     1610#        puts "vector 2 list = $vector2list"
     1611#        puts "number atoms = $::gcon_atoms"
     1612#        puts "start atom  = $::gcon_start"
    14561613
    14571614        set temp1 [ExtractRigidBody $::rb_phase $::gcon_atoms $::gcon_start $::gcon_origin_list $vector1list $vector2list]
     
    17831940                               $::rb_var($phasenum,$bodnum,$mapnum,s31) $::rb_var($phasenum,$bodnum,$mapnum,s32) \
    17841941                               $::rb_var($phasenum,$bodnum,$mapnum,saa) $::rb_var($phasenum,$bodnum,$mapnum,sbb)"
    1785                            puts "TLS param save for $rb_tls"
     1942#                           puts "TLS param save for $rb_tls"
    17861943                           RigidBodyTLSVary $phasenum $bodnum $mapnum $rb_tls
    17871944                           RecordMacroEntry "RigidBodyTLSVary $phasenum $bodnum $mapnum [list $rb_tls]" 0
     
    19722129    for {set coord 0} {$coord < $coordnummax} {incr coord} {
    19732130        set line [list $::rb_x($bodnum,1,$coord) $::rb_y($bodnum,1,$coord) $::rb_z($bodnum,1,$coord)]
    1974         puts $line
    1975         puts $fh $line
     2131#        puts $line
     2132#        puts $fh $line
    19762133    }
    19772134    close $fh
Note: See TracChangeset for help on using the changeset viewer.