Changeset 936 for trunk/GSASIImath.py


Ignore:
Timestamp:
May 30, 2013 9:05:36 AM (10 years ago)
Author:
vondreele
Message:

more MC/SA stuff
further drawing optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r934 r936  
    283283    return XYZ,Cart
    284284
    285 def UpdateMCSAxyz(Bmat,mcsaModels,RBData):
     285def UpdateMCSAxyz(Bmat,MCSA):
    286286    xyz = []
    287287    atTypes = []
    288288    iatm = 0
    289     for model in mcsaModels[1:]:        #skip the MD model
     289    for model in MCSA['Models'][1:]:        #skip the MD model
    290290        if model['Type'] == 'Atom':
    291291            xyz.append(model['Pos'][0])
     
    293293            iatm += 1
    294294        else:
    295             rideList = []
    296             RBRes = RBData[model['Type']][model['RBId']]
     295            RBRes = MCSA['rbData'][model['Type']][model['RBId']]
    297296            Pos = np.array(model['Pos'][0])
    298297            Qori = np.array(model['Ori'][0])
     
    309308                    for ride in seq[3]:
    310309                        Cart[ride] = prodQVQ(QuatA,Cart[ride]-Cart[seq[1]])+Cart[seq[1]]
    311                     rideList += seq[3]
    312             centList = set(range(len(Cart)))-set(rideList)
    313             if model['MolCent']:
    314                 cent = np.zeros(3)
    315                 for i in centList:
    316                     cent += Cart[i]
    317                 Cart -= cent/len(centList)
     310            if model['MolCent'][1]:
     311                Cart -= model['MolCent'][0]
    318312            for i,x in enumerate(Cart):
    319313                xyz.append(np.inner(Bmat,prodQVQ(Qori,x))+Pos)
     
    322316                iatm += 1
    323317    return np.array(xyz),atTypes
     318   
     319def SetMolCent(model,RBData):
     320    rideList = []
     321    RBRes = RBData[model['Type']][model['RBId']]
     322    if model['Type'] == 'Vector':
     323        vecs = RBRes['rbVect']
     324        mags = RBRes['VectMag']
     325        Cart = np.zeros_like(vecs[0])
     326        for vec,mag in zip(vecs,mags):
     327            Cart += vec*mag
     328    elif model['Type'] == 'Residue':
     329        Cart = np.array(RBRes['rbXYZ'])
     330        for seq in RBRes['rbSeq']:
     331            rideList += seq[3]
     332    centList = set(range(len(Cart)))-set(rideList)
     333    cent = np.zeros(3)
     334    for i in centList:
     335        cent += Cart[i]
     336    model['MolCent'][0] = cent/len(centList)   
    324337   
    325338def UpdateRBUIJ(Bmat,Cart,RBObj):
Note: See TracChangeset for help on using the changeset viewer.