コード例 #1
0
    def reset(self):

        #Make a cell
        cell = Mod.makeCell(self.crystalCell, self.spaceGroup.xtalSystem)

        #Define a model
        self.model = S.Model([], [],
                             self.backg,
                             self.wavelength,
                             self.spaceGroup,
                             cell, [self.atomList],
                             self.exclusions,
                             scale=0.06298,
                             error=[],
                             extinction=[0.0001054])

        #Set a range on the x value of the first atom in the model
        self.model.atomListModel.atomModels[0].z.value = 0.25
        self.model.atomListModel.atomModels[0].z.range(0, 0.5)

        self.visited = []
        self.observed = []
        self.remainingActions = []
        for i in range(len(self.refList)):
            self.remainingActions.append(i)

        self.totReward = 0
        self.prevChisq = None
        self.steps = 0

        self.state = np.zeros(len(self.refList))
        self.stateList = []

        return self.state
コード例 #2
0
def fit():
    cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)
    #cell.a.pm(5.0)
    #cell.c.pm(5.0)
    m = S.Model(tt,
                sfs2,
                backg,
                wavelength,
                spaceGroup,
                cell, (atomList, magAtomList),
                exclusions,
                magnetic=True,
                symmetry=symmetry,
                newSymmetry=basisSymmetry,
                scale=1.00,
                error=error,
                hkls=refList,
                extinction=[0, 0, 0, 0])
    m.scale.range(0, 2000)
    #m.base.pm(1000)
    for ext in m.extinctions:
        ext.range(0, 100.0)
    for atomModel in m.atomListModel.atomModels:
        #atomModel.x.range(0,1)
        #atomModel.y.range(0,1)
        #atomModel.z.range(0,1)
        #atomModel.B.range(0,10)
        if atomModel.magnetic:
            for coeff in atomModel.coeffs:
                coeff.range(-20, 20)
                #coeff.range(0,5)
    M = bumps.FitProblem(m)
    M.model_update()
    return M
コード例 #3
0
def graphError():

	cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)
	m = S.Model(tt, sfs2, backg, wavelength, spaceGroup, cell,
        	[atomList], exclusions,
        	scale=0.06298,hkls=refList, error=error,  extinction=[0.0001054])
	m.atomListModel.atomModels[0].z.range(0,0.5)

        z = 0
	xval = []
	y = []
	while (z < 0.5):

	    	#Set a range on the x value of the first atom in the model
    		m.atomListModel.atomModels[0].z.value = z
    		m.atomListModel.atomModels[0].z.range(0, 0.5)
    		problem = bumps.FitProblem(m)
		#    monitor = fitter.StepMonitor(problem, open("sxtalFitMonitor.txt","w"))

        	fitted = fitter.LevenbergMarquardtFit(problem)
    		x, dx = fitted.solve()
    		xval.append(x[0])
    		y.append(problem.chisq())
                print(x, problem.chisq())
    		z += 0.005

	fig = plt.figure()#
	mpl.pyplot.scatter(xval, yval)
	mpl.pyplot.xlabel("Pr z coordinate")
	mpl.pyplot.ylabel("X2 value")
	fig.savefig('/mnt/storage/prnio_chisq_vals_optcfl_lm.png')
コード例 #4
0
def plotSfs2():

	cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)
	m = S.Model(tt, sfs2, backg, wavelength, spaceGroup, cell,
        	[atomList], exclusions,
        	scale=0.06298,hkls=refList, error=error,  extinction=[0.0001054])
	m.atomListModel.atomModels[0].z.range(0,0.5)

        x = sfs2
        y = m.theory()

        plt.scatter(x, y)
        plt.savefig('sfs2s.png')
コード例 #5
0
def setInitParams():

    #Make a cell
    cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)

    #Define a model
    m = S.Model([], [], backg, wavelength, spaceGroup, cell,
                [atomList], exclusions,
                scale=0.06298, error=[],  extinction=[0.0001054])

    #Set a range on the x value of the first atom in the model
    #Replace this code with references to the parameters you would like to fit the model to
    m.atomListModel.atomModels[0].z.value = 0.3
    m.atomListModel.atomModels[0].z.range(0,0.5)

    return m
コード例 #6
0
ファイル: epGreedy.py プロジェクト: scattering/crystal-eg
def setInitParams():
    #Make a cell
    cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)
    #Define a model
    m = S.Model([], [], backg, wavelength, spaceGroup, cell,
                [atomList], exclusions,
                scale=0.2163, error=[],  extinction=[0.000105])
    #Set a range on the x value of the first atom in the model


    #Setting initial values and ranges of parameters to look at
    m.atomListModel.atomModels[0].z.value = 0.5
#    m.atomListModel.atomModels[0].z.value = random.random()/2
    m.atomListModel.atomModels[0].z.range(0,1)
    #Oxygen d z coordinate
#    m.atomListModel.atomModels[5].z.value = 0.2
#    m.atomListModel.atomModels[5].z.range(0,0.5)
    return m
コード例 #7
0
def fit():
    cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)
    #cell.a.pm(5.0)
    #cell.c.pm(5.0)
    m = S.Model(tt, sfs2, backg, wavelength, spaceGroup, cell,
                [atomList], exclusions,
                 scale=0.06298, error=error, hkls=refList, extinction=0.0001054)
    m.scale.range(0,100)
    #m.base.pm(1000)
    m.extinction.range(0,10.0)
    for atomModel in m.atomListModel.atomModels:
        #atomModel.x.range(0,1)
        #atomModel.y.range(0,1)
        #atomModel.z.range(0,1)
        #atomModel.B.range(0,10)
        if atomModel.magnetic:
            for coeff in atomModel.coeffs:
                coeff.range(-20, 20)
                #coeff.range(0,5)
    M = bumps.FitProblem(m)
    M.model_update()
    return M
コード例 #8
0
def fitFullModel():

	cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem)

	#Define a model
	m = S.Model(tt, sfs2, backg, wavelength, spaceGroup, cell,
        	[atomList], exclusions,
        	scale=0.06298,hkls=refList, error=error,  extinction=[0.0001054])

        m.u.range(0,2)
        m.zero.pm(0.1)
        m.v.range(-2,0)
        m.w.range(0,2)
        m.eta.range(0,1)
        m.scale.range(0,10)
        m.base.pm(250)

        for atomModel in m.atomListModel.atomModels:
            atomModel.x.pm(0.1)
            atomModel.z.pm(0.1)
            if (atomModel.atom.multip == atomModel.sgmultip):
                # atom lies on a general position
                atomModel.x.pm(0.1)
                atomModel.y.pm(0.1)
                atomModel.z.pm(0.1)

	m.atomListModel.atomModels[0].z.value = 0.3
	m.atomListModel.atomModels[0].z.range(0,0.5) 

   	problem = bumps.FitProblem(m)
        fitted = fitter.SimplexFit(problem)
    	x, dx = fitted.solve(steps=50)
        problem.model_update()

        print(problem.summarize())
        print(x, dx, problem.chisq())