Changeset 934 for trunk/GSASIImath.py


Ignore:
Timestamp:
May 28, 2013 4:29:16 PM (10 years ago)
Author:
vondreele
Message:

changes for MC/SA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r915 r934  
    282282        XYZ[i] = np.inner(Bmat,X)+RBObj['Orig'][0]
    283283    return XYZ,Cart
     284
     285def UpdateMCSAxyz(Bmat,mcsaModels,RBData):
     286    xyz = []
     287    atTypes = []
     288    iatm = 0
     289    for model in mcsaModels[1:]:        #skip the MD model
     290        if model['Type'] == 'Atom':
     291            xyz.append(model['Pos'][0])
     292            atTypes.append(model['atType'])
     293            iatm += 1
     294        else:
     295            rideList = []
     296            RBRes = RBData[model['Type']][model['RBId']]
     297            Pos = np.array(model['Pos'][0])
     298            Qori = np.array(model['Ori'][0])
     299            if model['Type'] == 'Vector':
     300                vecs = RBRes['rbVect']
     301                mags = RBRes['VectMag']
     302                Cart = np.zeros_like(vecs[0])
     303                for vec,mag in zip(vecs,mags):
     304                    Cart += vec*mag
     305            elif model['Type'] == 'Residue':
     306                Cart = np.array(RBRes['rbXYZ'])
     307                for itor,seq in enumerate(RBRes['rbSeq']):
     308                    QuatA = AVdeg2Q(model['Tor'][0][itor],Cart[seq[0]]-Cart[seq[1]])
     309                    for ride in seq[3]:
     310                        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)
     318            for i,x in enumerate(Cart):
     319                xyz.append(np.inner(Bmat,prodQVQ(Qori,x))+Pos)
     320                atType = RBRes['rbTypes'][i]
     321                atTypes.append(atType)
     322                iatm += 1
     323    return np.array(xyz),atTypes
    284324   
    285325def UpdateRBUIJ(Bmat,Cart,RBObj):
     
    13601400        XY = [pos,0,mag,1,alp,0,bet,0,sig,0,gam,0]
    13611401    return XY
     1402
     1403def mcsaSearch(data,reflType,reflData,covData,pgbar):
     1404    generalData = data['General']
     1405    mcsaControls = generalData['MCSA controls']
     1406    reflName = mcsaData['Data source']
     1407    phaseName = generalData['Name']
     1408    MCSAObjs = data['MCSAModels']
     1409           
     1410#             = {'':'','Annealing':[50.0,0.001,0.90,1000],
     1411#            'dmin':2.0,'Algolrithm':'Normal','Jump coeff':[0.95,0.5]} #'Normal','Random jump','Tremayne jump'
     1412
     1413    return {}
     1414
    13621415       
    13631416def getWave(Parms):
     
    14401493        V /= d
    14411494    else:
    1442         return [0.,0.,0.,1.]    #identity
     1495        V = np.array([0.,0.,1.])
    14431496    p = A/2.
    14441497    Q[0] = np.cos(p)
     
    14551508        V /= d
    14561509    else:
    1457         return [0.,0.,0.,1.]    #identity
     1510        V = np.array([0.,0.,1.])
    14581511    p = A/2.
    14591512    Q[0] = cosd(p)
     
    14671520    A = 2.*acosd(Q[0])
    14681521    V = np.array(Q[1:])
    1469     if nl.norm(Q[1:]):
    1470         V = Q[1:]/nl.norm(Q[1:])
     1522    d = np.sqrt(np.sum(V**2))
     1523    if d:
     1524        V /= d
    14711525    else:
    14721526        A = 0.
    1473         V = np.array([0.,0.,1.])
     1527        V = np.array([0.,0.,0.])
    14741528    return A,V
    14751529   
     
    14801534    A = 2.*np.arccos(Q[0])
    14811535    V = np.array(Q[1:])
    1482     if nl.norm(Q[1:]):
    1483         V = Q[1:]/nl.norm(Q[1:])
     1536    d = np.sqrt(np.sum(V**2))
     1537    if d:
     1538        V /= d
    14841539    else:
    14851540        A = 0.
    1486         V = np.array([0.,0.,1.])
     1541        V = np.array([0.,0.,0.])
    14871542    return A,V
    14881543   
Note: See TracChangeset for help on using the changeset viewer.