Changeset 4263 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Jan 22, 2020 9:49:36 AM (21 months ago)
Author:
vondreele
Message:

major revision of RMCProfile GUI - now shows in data window instead of a dialog
additions of atom-atom and atom-atom-aton potentials & coordination no. restraints
tested with RMCProfile 6.7.6 (serial)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r4254 r4263  
    21072107        if useSamBrd[0]:
    21082108            if 'ellipsoidal' not in Size[0]:    #take the isotropic term only
    2109                 Xsb = 1.e-4*difC/Size[1][0]
     2109                Xsb = 1.e-4*difC/Size[1][0]/2.
    21102110        if useSamBrd[1]:
    21112111            if 'generalized' not in Mustrain[0]:    #take the isotropic term only
    2112                 Ysb = 1.e-6*difC*Mustrain[1][0]
     2112                Ysb = 1.e-6*difC*Mustrain[1][0]/2.
    21132113        prms = ['Bank',
    21142114                'difC','difA','Zero','2-theta',
     
    21232123        fl.write('%12.6e%14.6e%14.6e\n'%(inst[prms[5]][1],inst[prms[6]][1],inst[prms[7]][1]))
    21242124        fl.write('%12.6e%14.6e%14.6e\n'%(inst[prms[8]][1],inst[prms[9]][1],inst[prms[10]][1]))   
    2125         fl.write('%12.6e%14.6e%14.6e%14.6e%14.6e\n'%(inst[prms[11]][1],inst[prms[12]][1]+Ysb,inst[prms[13]][1]+Xsb,0.0,0.0))
     2125        fl.write('%12.6e%14.6e%14.6e%14.6e%14.6e\n'%(inst[prms[11]][1],inst[prms[12]][1]+Xsb,inst[prms[13]][1]+Ysb,0.0,0.0))
    21262126        fl.close()
    21272127    else:
     
    21292129            wave = G2mth.getWave(inst)
    21302130            if 'ellipsoidal' not in Size[0]:    #take the isotropic term only
    2131                 Xsb = 1.8*wave/(np.pi*Size[1][0])
     2131                Xsb = 1.8*wave/(np.pi*Size[1][0])/2.
    21322132        if useSamBrd[1]:
    21332133            if 'generalized' not in Mustrain[0]:    #take the isotropic term only
    2134                 Ysb = 0.018*np.pi*Mustrain[1][0]
     2134                Ysb = 0.018*np.pi*Mustrain[1][0]/2.
    21352135        prms = ['Bank',
    21362136                'Lam','Zero','Polariz.',
     
    21682168
    21692169def MakeRMC6f(G2frame,Name,Phase,RMCPdict,PWId):
     2170   
     2171    def findDup(Atoms):
     2172        Dup = []
     2173        Fracs = []
     2174        for iat1,at1 in enumerate(Atoms):
     2175            if any([at1[0] in dup for dup in Dup]):
     2176                continue
     2177            else:
     2178                Dup.append([at1[0],])
     2179                Fracs.append([at1[6],])
     2180            for iat2,at2 in enumerate(Atoms[(iat1+1):]):
     2181                if np.sum((np.array(at1[3:6])-np.array(at2[3:6]))**2) < 0.00001:
     2182                    Dup[-1] += [at2[0],]
     2183                    Fracs[-1]+= [at2[6],]
     2184        return Dup,Fracs
     2185   
    21702186    Meta = RMCPdict['metadata']
    21712187    Atseq = RMCPdict['atSeq']
     
    21732189    PWDdata = G2frame.GetPWDRdatafromTree(PWId)
    21742190    generalData = Phase['General']
     2191    Dups,Fracs = findDup(Phase['Atoms'])
     2192    Sfracs = [np.cumsum(fracs) for fracs in Fracs]
    21752193    Sample = PWDdata['Sample Parameters']
    21762194    Meta['temperature'] = Sample['Temperature']
     
    21852203    Natm = np.count_nonzero(Natm-1)
    21862204    Atoms = newPhase['Atoms']
     2205    Satoms = G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(Atoms,5),4),3)
     2206    Datoms = [[atom for atom in Satoms if atom[0] in dup] for dup in Dups]
     2207    Natoms = []
     2208    for idup,dup in enumerate(Dups):
     2209        ldup = len(dup)
     2210        datoms = Datoms[idup]
     2211        natm = len(datoms)
     2212        i = 0
     2213        while i < natm:
     2214            atoms = datoms[i:i+ldup]
     2215            try:
     2216                atom = atoms[np.searchsorted(Sfracs[idup],rand.random())]
     2217                Natoms.append(atom)
     2218            except IndexError:      #what about vacancies?
     2219                pass
     2220            i += ldup
    21872221    NAtype = np.zeros(len(Atseq))
    2188     for atom in Atoms:
     2222    for atom in Natoms:
    21892223        NAtype[Atseq.index(atom[1])] += 1
    21902224    NAstr = ['%d'%i for i in NAtype]
     
    22012235    fl.write('Atom types present:             %s\n'%'    '.join(Atseq))
    22022236    fl.write('Number of each atom type:       %s\n'%'  '.join(NAstr))
    2203     fl.write('Number of atoms:                %d\n'%len(Atoms))
     2237    fl.write('Number of atoms:                %d\n'%len(Natoms))
    22042238    fl.write('%-35s%4d%4d%4d\n'%('Supercell dimensions:',Supercell[0],Supercell[1],Supercell[2]))
    22052239    fl.write('Cell (Ang/deg): %12.6f%12.6f%12.6f%12.6f%12.6f%12.6f\n'%(
     
    22122246    nat = 0
    22132247    for atm in Atseq:
    2214         for iat,atom in enumerate(Atoms):
     2248        for iat,atom in enumerate(Natoms):
    22152249            if atom[1] == atm:
    22162250                nat += 1
     
    22382272    fname = Name+'.bragg'
    22392273    fl = open(fname,'w')
    2240     fl.write('%12d%6d%15.7f%15.4f\n'%(Ifin-Ibeg-1,Bank,Scale,Vol))
     2274    fl.write('%12d%6d%15.7f%15.4f\n'%(Ifin-Ibeg-2,Bank,Scale,Vol))
    22412275    if 'T' in Inst['Type'][0]:
    22422276        fl.write('%12s%12s\n'%('   TOF,ms','  I(obs)'))
     
    22452279    else:
    22462280        fl.write('%12s%12s\n'%('   2-theta, deg','  I(obs)'))
     2281        DT = np.diff(Data[0])
    22472282        for i in range(Ibeg,Ifin-1):
    2248             fl.write('%11.6f%15.2f\n'%(Data[0][i],Data[1][i]))       
     2283            fl.write('%11.6f%15.2f\n'%(Data[0][i]-DT[i],Data[1][i]))       
    22492284    fl.close()
    22502285    return fname
     
    23092344    fl.write('INPUT_CONFIGURATION_FORMAT ::  rmc6f\n')
    23102345    fl.write('SAVE_CONFIGURATION_FORMAT  ::  rmc6f\n')
     2346    fl.write('\n')
    23112347    fl.write('DISTANCE_WINDOW ::\n')
    23122348    fl.write('  > MNDIST :: %s\n'%minD)
    23132349    fl.write('  > MXDIST :: %s\n'%maxD)
     2350    if len(RMCPdict['Potentials']['Stretch']) or len(RMCPdict['Potentials']['Stretch']):
     2351        fl.write('\n')
     2352        fl.write('POTENTIALS ::\n')
     2353        if len(RMCPdict['Potentials']['Stretch']):
     2354            fl.write('  > STRETCH_SEARCH :: %.1f%%\n'%RMCPdict['Potentials']['Stretch search'])
     2355            for bond in RMCPdict['Potentials']['Stretch']:
     2356                fl.write('  > STRETCH :: %s %s %.2f eV %.2f Ang\n'%(bond[0],bond[1],bond[3],bond[2]))       
     2357        if len(RMCPdict['Potentials']['Angles']):
     2358            fl.write('  > ANGLE_SEARCH :: %.1f%%\n'%RMCPdict['Potentials']['Angle search'])
     2359            for angle in RMCPdict['Potentials']['Angles']:
     2360                fl.write('  > ANGLE :: %s %s %s %.2f eV %.2f deg %.2f Ang %.2f Ang\n'%
     2361                    (angle[1],angle[0],angle[2],angle[6],angle[3],angle[4],angle[5]))
    23142362    if RMCPdict['useBVS']:
    23152363        fl.write('BVS ::\n')
     
    23642412                    fl.write('  > REAL_SPACE_FIT :: 1 3000 1\n')
    23652413                    fl.write('  > REAL_SPACE_PARAMETERS :: 1 3000 %.4f\n'%Files[File][1])
     2414    fl.write('\n')
    23662415    fl.write('BRAGG ::\n')
    23672416    fl.write('  > BRAGG_SHAPE :: %s\n'%gsasType)
Note: See TracChangeset for help on using the changeset viewer.