Changeset 1139 for branches/sandbox


Ignore:
Timestamp:
Apr 28, 2011 10:45:44 AM (10 years ago)
Author:
lake
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/rb.tcl

    r1138 r1139  
    103103#   rbnum is the rigid body type number
    104104#   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
    106106#      for the body, the unspecified variable will not be changed
    107107#   damplist   is a list of damping values (0-9)
    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
    109109#      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
    112112#       damping values
    113 #  SetRigidBodVar 3 {} {0 0 0} 
     113#  SetRigidBodVar 3 {} {0 0 0}
    114114#       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}
    116116#      changes both variable numbers and damping at the same time
    117117# Nothing is returned
     
    137137            if {$damp < 0} {set damp 0}
    138138            validint damp 5
    139             setexp "${key}${i}PARM" $damp 16 20
    140         }
     139        }
     140        setexp "${key}${i}PARM" $damp 16 20
    141141    }
    142142}
     
    416416# AddRigidBody: add a new rigid body definition into the .EXP file
    417417# 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
    419419#             simplest case this will be {1}
    420420#   coordlist: a nested list of coordinates such as { { {0 0 0} {.1 .1 .1} {.2 .2 .2} } }
    421421# 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
    428428#    atom 1 = s1 * (0,0,0) + s2*(0,0,0) [ = (0,0,0)]
    429429#    atom 2 = s1 * (1,1,0) + s2*(1,1,0) [ = (s1+s2) * (1,1,0)]
     
    440440    }
    441441    # did we go too far?
    442     if {$rbnum == 16} {return ""} 
     442    if {$rbnum == 16} {return ""}
    443443    # increment the RB counter
    444444    set n [string trim [readexp "RGBD  NRBDS"]]
     
    455455
    456456# 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,
    458458# but if it does, the simplifed approach used here will fail, so this
    459 # is not allowed. 
     459# is not allowed.
    460460# Input:
    461461#   Rigid body number
     
    482482        return -3
    483483    }
    484     # delete the records starting with "RGBD x" or "RGBD10" 
     484    # delete the records starting with "RGBD x" or "RGBD10"
    485485    foreach key [array names ::exparray "${key}*"] {
    486486        #puts $key
     
    503503
    504504# 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
    506506# than added.
    507507# Note that count of the # of times the body is used is preserved
    508 proc ReplaceRigidBody {rbnum multlist coordlist} {
     508proc ReplaceRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} {
    509509    set value $rbnum
    510510    validint value 2
     
    515515        delexp $key
    516516    }
    517     SetRigidBody $rbnum $multlist $coordlist
     517    SetRigidBody $rbnum $multlist $coordlist $varlist $damplist
    518518    setexp "$key NBDS" $line 1 68
    519519}
    520520
    521 # Edit the parameters for rigid body #rbnum 
     521# Edit the parameters for rigid body #rbnum
    522522# (normally called from ReplaceRigidBody or AddRigidBody)
    523 proc SetRigidBody {rbnum multlist coordlist} {
     523proc SetRigidBody {rbnum multlist coordlist {varlist ""} {damplist ""}} {
    524524    set value $rbnum
    525525    validint value 2
     
    528528    set value [llength [lindex $coordlist 0]]
    529529    validint value 5
    530     if {! [existsexp "$key NATR"]} {
    531         makeexprec "$key NATR"
    532     }
     530    makeexprec "$key NATR"
    533531    setexp "$key NATR" $value 1 5
    534532    # number of times used
    535533    set value 0
    536534    validint value 5
    537     if {! [existsexp "$key NBDS"]} {
    538         makeexprec "$key NBDS"
    539     }
     535    makeexprec "$key NBDS"
    540536    setexp "$key NBDS" $value 1 5
    541537    # number of coordinate matrices
    542538    set value [llength $multlist]
    543539    validint value 5
    544     if {! [existsexp "$key NSMP"]} {
    545         makeexprec "$key NSMP"
    546     }
     540    makeexprec "$key NSMP"
    547541    setexp "$key NSMP" $value 1 5
    548542    set i 0
    549543    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}
    550548        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
    555551        set j 0
    556552        foreach item $coords {
     
    559555            set value $j
    560556            validint value 3
    561             if {! [existsexp "${key}${i}SC$value"]} {
    562                 makeexprec "${key}${i}SC$value"
    563             }
     557            makeexprec "${key}${i}SC$value"
    564558            if {[llength $item] == 4} {
    565559                setexp "${key}${i}SC$value" [eval format "%10.6f%10.6f%10.6f%10s" $item] 1 40
     
    601595    }
    602596    # did we go too far?
    603     if {$rbnum == 16} {return ""} 
     597    if {$rbnum == 16} {return ""}
    604598    # increment number of mapped bodies of this type overall
    605599    set value $bodytyp
Note: See TracChangeset for help on using the changeset viewer.