Changeset 1139
 Timestamp:
 Apr 28, 2011 10:45:44 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/sandbox/rb.tcl
r1138 r1139 103 103 # rbnum is the rigid body type number 104 104 # varnumlist is a list of variable numbers 105 # note that if this list is shorter than the number of actual multipliers 105 # note that if this list is shorter than the number of actual multipliers 106 106 # for the body, the unspecified variable will not be changed 107 107 # damplist is a list of damping values (09) 108 # note that if the damplist is shorter than the number of actual multipliers 108 # note that if the damplist is shorter than the number of actual multipliers 109 109 # the unspecified values are not changed 110 # SetRigidBodVar 2 {1 2 3} {} 111 # will vary the (first 3) translations in body #3 and will not change the 110 # SetRigidBodVar 2 {1 2 3} {} 111 # will vary the (first 3) translations in body #3 and will not change the 112 112 # damping values 113 # SetRigidBodVar 3 {} {0 0 0} 113 # SetRigidBodVar 3 {} {0 0 0} 114 114 # will not change variable settings but will change the (first 3) damping values 115 # SetRigidBodVar 4 {11 11} {8 8} 115 # SetRigidBodVar 4 {11 11} {8 8} 116 116 # changes both variable numbers and damping at the same time 117 117 # Nothing is returned … … 137 137 if {$damp < 0} {set damp 0} 138 138 validint damp 5 139 setexp "${key}${i}PARM" $damp 16 20140 }139 } 140 setexp "${key}${i}PARM" $damp 16 20 141 141 } 142 142 } … … 416 416 # AddRigidBody: add a new rigid body definition into the .EXP file 417 417 # arguments are: 418 # multlist: defines a list of multipliers for each set of coordinates. In the 418 # multlist: defines a list of multipliers for each set of coordinates. In the 419 419 # simplest case this will be {1} 420 420 # coordlist: a nested list of coordinates such as { { {0 0 0} {.1 .1 .1} {.2 .2 .2} } } 421 421 # note that when the length of multlist > 1 then coordlist must have the same length. 422 # for input where 423 # multlist = {s1 s2} and 424 # coordlist = { { {0 0 0} {1 1 0} {.0 .0 .0} ...} 425 # {0 0 0} {1 1 0} {2 1 2} ...} 426 # } 427 # the cartesian coordinates are defined from the input as 422 # for input where 423 # multlist = {s1 s2} and 424 # coordlist = { { {0 0 0} {1 1 0} {.0 .0 .0} ...} 425 # {0 0 0} {1 1 0} {2 1 2} ...} 426 # } 427 # the cartesian coordinates are defined from the input as 428 428 # atom 1 = s1 * (0,0,0) + s2*(0,0,0) [ = (0,0,0)] 429 429 # atom 2 = s1 * (1,1,0) + s2*(1,1,0) [ = (s1+s2) * (1,1,0)] … … 440 440 } 441 441 # did we go too far? 442 if {$rbnum == 16} {return ""} 442 if {$rbnum == 16} {return ""} 443 443 # increment the RB counter 444 444 set n [string trim [readexp "RGBD NRBDS"]] … … 455 455 456 456 # DeleteRigidBody: remove a rigid body definition from the .EXP file 457 # The body may not be mapped. I am not sure if GSAS allows more than 9 bodies, 457 # The body may not be mapped. I am not sure if GSAS allows more than 9 bodies, 458 458 # but if it does, the simplifed approach used here will fail, so this 459 # is not allowed. 459 # is not allowed. 460 460 # Input: 461 461 # Rigid body number … … 482 482 return 3 483 483 } 484 # delete the records starting with "RGBD x" or "RGBD10" 484 # delete the records starting with "RGBD x" or "RGBD10" 485 485 foreach key [array names ::exparray "${key}*"] { 486 486 #puts $key … … 503 503 504 504 # ReplaceRigidBody: replace all the information for rigid body #rbnum 505 # Works the sames as AddRigidBody (see above) except that the rigid body is replaced rather 505 # Works the sames as AddRigidBody (see above) except that the rigid body is replaced rather 506 506 # than added. 507 507 # Note that count of the # of times the body is used is preserved 508 proc ReplaceRigidBody {rbnum multlist coordlist } {508 proc ReplaceRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} { 509 509 set value $rbnum 510 510 validint value 2 … … 515 515 delexp $key 516 516 } 517 SetRigidBody $rbnum $multlist $coordlist 517 SetRigidBody $rbnum $multlist $coordlist $varlist $damplist 518 518 setexp "$key NBDS" $line 1 68 519 519 } 520 520 521 # Edit the parameters for rigid body #rbnum 521 # Edit the parameters for rigid body #rbnum 522 522 # (normally called from ReplaceRigidBody or AddRigidBody) 523 proc SetRigidBody {rbnum multlist coordlist } {523 proc SetRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} { 524 524 set value $rbnum 525 525 validint value 2 … … 528 528 set value [llength [lindex $coordlist 0]] 529 529 validint value 5 530 if {! [existsexp "$key NATR"]} { 531 makeexprec "$key NATR" 532 } 530 makeexprec "$key NATR" 533 531 setexp "$key NATR" $value 1 5 534 532 # number of times used 535 533 set value 0 536 534 validint value 5 537 if {! [existsexp "$key NBDS"]} { 538 makeexprec "$key NBDS" 539 } 535 makeexprec "$key NBDS" 540 536 setexp "$key NBDS" $value 1 5 541 537 # number of coordinate matrices 542 538 set value [llength $multlist] 543 539 validint value 5 544 if {! [existsexp "$key NSMP"]} { 545 makeexprec "$key NSMP" 546 } 540 makeexprec "$key NSMP" 547 541 setexp "$key NSMP" $value 1 5 548 542 set i 0 549 543 foreach mult $multlist coords $coordlist { 544 set var [lindex $varlist $i] 545 if {$var == ""} {set var 0} 546 set damp [lindex $damplist $i] 547 if {$damp == ""} {set damp 0} 550 548 incr i 551 if {! [existsexp "${key}${i}PARM"]} { 552 makeexprec "${key}${i}PARM" 553 } 554 setexp "${key}${i}PARM" [format "%10.5f%5d%5d" $mult 0 0] 1 20 549 makeexprec "${key}${i}PARM" 550 setexp "${key}${i}PARM" [format "%10.5f%5d%5d" $mult $var $damp] 1 20 555 551 set j 0 556 552 foreach item $coords { … … 559 555 set value $j 560 556 validint value 3 561 if {! [existsexp "${key}${i}SC$value"]} { 562 makeexprec "${key}${i}SC$value" 563 } 557 makeexprec "${key}${i}SC$value" 564 558 if {[llength $item] == 4} { 565 559 setexp "${key}${i}SC$value" [eval format "%10.6f%10.6f%10.6f%10s" $item] 1 40 … … 601 595 } 602 596 # did we go too far? 603 if {$rbnum == 16} {return ""} 597 if {$rbnum == 16} {return ""} 604 598 # increment number of mapped bodies of this type overall 605 599 set value $bodytyp
Note: See TracChangeset
for help on using the changeset viewer.