Changeset 5320


Ignore:
Timestamp:
Aug 21, 2022 10:16:38 AM (16 months ago)
Author:
toby
Message:

more fullrmc work (all but swaps done?); misc docs fixes

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r5257 r5320  
    7575
    7676    :param wx.Frame G2frame: main GSAS-II frame
    77     :param: dict data: Image Controls dictionary
     77    :param dict data: Image Controls dictionary
    7878
    7979    :returns: array sumImg: corrected image for background/dark/flat back
  • trunk/GSASIImath.py

    r5312 r5320  
    858858   
    859859    :param dict data: GSAS-II phase data structure
    860     :param: dict seqData: GSAS-II sequential refinement results structure
     860    :param dict seqData: GSAS-II sequential refinement results structure
    861861    :param bool PF2: if True then seqData is from a sequential run of PDFfit2
    862862   
  • trunk/GSASIIphsGUI.py

    r5317 r5320  
    55865586                    mainSizer.Add(grpBox,0)
    55875587
     5588            RMCPdict['addThermalBroadening'] = RMCPdict.get('addThermalBroadening',False)
     5589            mainSizer.Add((-1,5))
     5590            distBox = wx.BoxSizer(wx.HORIZONTAL)
     5591            distBox.Add(wx.StaticText(G2frame.FRMC,label=' Add thermal broadening? '),0,WACV)
     5592            distBox.Add(G2G.G2CheckBox(G2frame.FRMC,'',RMCPdict,'addThermalBroadening',OnChange=UpdateRMC),
     5593                            0,WACV)
     5594            if RMCPdict['addThermalBroadening']:
     5595                distBox.Add((15,-1))
     5596                distBox.Add(wx.StaticText(G2frame.FRMC,label='Uiso equiv.'),0,WACV)
     5597                RMCPdict['ThermalU'] = RMCPdict.get('ThermalU',{})
     5598                for atm in RMCPdict['aTypes']:
     5599                    RMCPdict['ThermalU'][atm] = RMCPdict['ThermalU'].get(atm,0.005)
     5600                    distBox.Add(wx.StaticText(G2frame.FRMC,label='  '+atm+':'),0,WACV)
     5601                    distBox.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['ThermalU'],atm,
     5602                                                xmin=0.0001,xmax=0.25,size=(50,25)),0,WACV)
     5603            mainSizer.Add(distBox,0)
     5604            if RMCPdict['addThermalBroadening']: mainSizer.Add((-1,5))
     5605                   
    55885606            # Torsions are difficult to implement. Need to be internal to a unit cell & named with fullrmc
    55895607            # atom labels. Leave this out, at least for now.
     
    68696887        G2frame.GPXtree.SetItemPyData(psub,G2obj.SetNewPhase(Name=PhaseName,SGData=SGData))
    68706888        newPhase = G2frame.GPXtree.GetItemPyData(psub)
    6871         # add a restraint tree entry
    6872         subr = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Restraints')
    6873         G2frame.GPXtree.GetItemPyData(subr).update({PhaseName:{}})
    68746889        # read in info from file
    68756890        pName = (G2frame.GSASprojectfile.split('.')[0] + '-'
    68766891                     + data['General']['Name'])
    68776892        pName = pName.replace(' ','_')
    6878         with open(pName+'-fullrmc.atoms','r') as fp:
    6879             cell = [float(i) for i in fp.readline().split(':')[1].split()]
    6880             supercell = [int(i) for i in fp.readline().split(':')[1].split()]
    6881             if super:
    6882                 for i in range(3): cell[i] *= supercell[i]
    6883             # set cell & volume
    6884             newPhase['General']['Cell'][1:7] = cell
    6885             newPhase['General']['Cell'][7] = G2lat.calc_V(G2lat.cell2A(cell))
    6886             A,B = G2lat.cell2AB(cell)
    6887             # add atoms
    6888             for line in fp:
    6889                 Name,El,ox,oy,oz = line.split()
    6890                 oxyz = [float(i) for i in (ox,oy,oz)]
     6893        try:
     6894            with open(pName+'-fullrmc.atoms','r') as fp:
     6895                cell = [float(i) for i in fp.readline().split(':')[1].split()]
     6896                supercell = [int(i) for i in fp.readline().split(':')[1].split()]
    68916897                if super:
    6892                     (x,y,z) = np.inner(B,oxyz)
    6893                 else:
    6894                     (x,y,z),disp = G2spc.MoveToUnitCell(np.inner(B,oxyz))
    6895                 atId = ran.randint(0,sys.maxsize)
    6896                 newPhase['Atoms'].append([Name,El,'',x,y,z,1.,'1',1,'I',0.01,0,0,0,0,0,0,atId])
    6897 
     6898                    for i in range(3): cell[i] *= supercell[i]
     6899                # set cell & volume
     6900                newPhase['General']['Cell'][1:7] = cell
     6901                newPhase['General']['Cell'][7] = G2lat.calc_V(G2lat.cell2A(cell))
     6902                A,B = G2lat.cell2AB(cell)
     6903                # add atoms
     6904                for line in fp:
     6905                    Name,El,ox,oy,oz = line.split()
     6906                    oxyz = [float(i) for i in (ox,oy,oz)]
     6907                    if super:
     6908                        (x,y,z) = np.inner(B,oxyz)
     6909                    else:
     6910                        (x,y,z),disp = G2spc.MoveToUnitCell(np.inner(B,oxyz))
     6911                    atId = ran.randint(0,sys.maxsize)
     6912                    newPhase['Atoms'].append([Name,El,'',x,y,z,1.,'1',1,'I',0.01,0,0,0,0,0,0,atId])
     6913        except:
     6914            G2G.G2MessageBox(G2frame,
     6915                    'Unable to open or read file '+pName+'-fullrmc.atoms. '
     6916                    'Was a fullrmc run from the current .gpx file '
     6917                    'and for the current phase?',
     6918                    'Error on read')
     6919            G2frame.GPXtree.Delete(psub)
     6920            return
     6921        # add a restraint tree entry for new phase
     6922        subr = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Restraints')
     6923        G2frame.GPXtree.GetItemPyData(subr).update({PhaseName:{}})
    68986924        SetupGeneral()  # index elements
    68996925       
  • trunk/GSASIIpwd.py

    r5317 r5320  
    36873687    Files = RMCPdict['files']
    36883688    rundata = ''
    3689     rundata += '#### fullrmc %s file; edit by hand if you so choose #####\n'%scrname
     3689    rundata += '## fullrmc %s file ##\n## OK to edit this by hand ##\n'%scrname
    36903690    rundata += '# created in '+__file__+" v"+filversion.split()[1]
    36913691    rundata += dt.datetime.strftime(dt.datetime.now()," at %Y-%m-%dT%H:%M\n")
     
    37193719# utility routines
    37203720def writeHeader(ENGINE,statFP):
    3721     'header for stats file'
     3721    """header for stats file"""
    37223722    statFP.write('generated-steps, total-error, ')
    37233723    for c in ENGINE.constraints:
     
    37283728   
    37293729def writeCurrentStatus(ENGINE,statFP,plotF):
    3730     'line in stats file & current constraint plots'
     3730    """line in stats file & current constraint plots"""
    37313731    statFP.write(str(ENGINE.generated))
    37323732    statFP.write(', ')
     
    37493749
    37503750def calcRmax(ENGINE):
    3751     'from Bachir, works for non-orthorhombic cells'
     3751    """from Bachir, works for non-orthorhombic cells"""
    37523752    a,b,c = ENGINE.basisVectors
    37533753    lens = []
     
    37593759    lens.extend( [ts/np.linalg.norm(a), ts/np.linalg.norm(c)] )
    37603760    return min(lens)
    3761 
     3761'''
     3762    if RMCPdict.get('Groups',[]): rundata += '''
    37623763def makepdb(atoms, coords, bbox=None):
    3763     'creates a supercell directly from atom info'
     3764    """creates a supercell directly from atom info"""
    37643765    # used when ENGINE.build_crystal_set_pdb is not called
    37653766    prevcell = None
     
    39183919            rundata += '    ENGINE.add_constraints([GofR])\n'
    39193920            rundata += '    GofR.set_limits((None, calcRmax(ENGINE)))\n'
     3921            if RMCPdict['addThermalBroadening']:
     3922                rundata += "    GofR.set_thermal_corrections({'defaultFactor': 0.001})\n"
     3923                rundata += "    GofR.thermalCorrections['factors'] = {\n"
     3924                RMCPdict['addThermalBroadening']
     3925                for atm1 in RMCPdict['aTypes']:
     3926                    for atm2 in RMCPdict['aTypes']:
     3927                        rundata += "         ('{}', '{}'): {},\n".format(
     3928                            atm1,atm2,
     3929                            (RMCPdict['ThermalU'].get(atm1,0.005)+                                           RMCPdict['ThermalU'].get(atm2,0.005))/2)
     3930                rundata += '    }\n'
    39203931        elif '(Q)' in File:
    39213932            rundata += '    SOQ = np.loadtxt(os.path.join(dirName,"%s")).T\n'%filDat[0]
  • trunk/GSASIIscriptable.py

    r5307 r5320  
    851851    datadir = "/Users/toby/software/G2/Tutorials/PythonScript/data"
    852852    PathWrap = lambda fil: os.path.join(datadir,fil)
    853     gpx = G2sc.G2Project(filename='PbSO4sim.gpx') # create a project   
     853    gpx = G2sc.G2Project(newgpx='PbSO4sim.gpx') # create a project   
    854854    phase0 = gpx.add_phase(PathWrap("PbSO4-Wyckoff.cif"),
    855855             phasename="PbSO4",fmthint='CIF') # add a phase to the project
     
    878878    cifdir = "/Users/toby/software/G2/Tutorials/PythonScript/data"
    879879    datadir = "/Users/toby/software/G2/Tutorials/TOF-CW Joint Refinement/data"
    880     gpx = G2sc.G2Project(filename='/tmp/PbSO4simT.gpx') # create a project
     880    gpx = G2sc.G2Project(newgpx='/tmp/PbSO4simT.gpx') # create a project
    881881    phase0 = gpx.add_phase(os.path.join(cifdir,"PbSO4-Wyckoff.cif"),
    882882             phasename="PbSO4",fmthint='CIF') # add a phase to the project
     
    972972    PathWrap = lambda fil: os.path.join(datadir,fil)
    973973
    974     gpx = G2sc.G2Project(filename=PathWrap('inttest.gpx'))
     974    gpx = G2sc.G2Project(newgpx=PathWrap('inttest.gpx'))
    975975    imlst = gpx.add_image(PathWrap('Si_free_dc800_1-00000.tif'),fmthint="TIF")
    976976    imlst[0].loadControls(PathWrap('Si_free_dc800_1-00000.imctrl'))
     
    990990        fil)
    991991
    992     gpx = G2sc.G2Project(filename='/tmp/img.gpx')
     992    gpx = G2sc.G2Project(newgpx='/tmp/img.gpx')
    993993    for f in glob.glob(PathWrap('*.tif')):
    994994        im = gpx.add_image(f,fmthint="TIF")
     
    10441044        fil)
    10451045
    1046     gpx = G2sc.G2Project(filename='/tmp/calib.gpx')
     1046    gpx = G2sc.G2Project(newgpx='/tmp/calib.gpx')
    10471047    for f in glob.glob(PathWrap('*.tif')):
    10481048        im = gpx.add_image(f,fmthint="TIF")
     
    20182018    :param str newgpx: The filename the project should be saved to in
    20192019            the future. If both newgpx and gpxfile are present, the project is
    2020             loaded from the gpxfile, then when saved will be written to newgpx.
    2021     :param str filename: Name to be used to save the project. Has same function as
    2022             parameter newgpx (do not use both gpxfile and filename). Use of newgpx
    2023             is preferred over filename.
     2020            loaded from the file named by gpxfile and then when saved will
     2021            be written to the file named by newgpx.
     2022    :param str filename: To be deprecated. Serves the same function as newgpx,
     2023            which has a somewhat more clear name.
     2024            (Do not specify both newgpx and filename).
    20242025
    20252026    There are two ways to initialize this object:
     
    20612062        if filename is not None and newgpx is not None:
    20622063            raise G2ScriptException('Do not use filename and newgpx together')
     2064        elif filename is not None:
     2065            G2fil.G2Print("Warning - recommending use of parameter newgpx rather than filename\n\twhen creating a G2Project")
    20632066        elif newgpx:
    20642067            filename = newgpx
     
    57115714        Example:
    57125715
    5713         >>> sclEnt = p.getHAPentryList(0,'Scale')[0]                                    >>> sclEnt
     5716        >>> sclEnt = p.getHAPentryList(0,'Scale')[0]
     5717        >>> sclEnt
    57145718        [(['PWDR test Bank 1', 'Scale'], list, [1.0, False])]
    57155719        >>> p.getHAPentryValue(sclEnt[0])
     
    62376241    Example use of G2Image:
    62386242
    6239     >>> gpx = G2sc.G2Project(filename='itest.gpx')
     6243    >>> gpx = G2sc.G2Project(newgpx='itest.gpx')
    62406244    >>> imlst = gpx.add_image(idata,fmthint="TIF")
    62416245    >>> imlst[0].loadControls('stdSettings.imctrl')
Note: See TracChangeset for help on using the changeset viewer.