예제 #1
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, 'baseline', which))
    #endif

    print '>>>>>> %s' % folder

    data = read_xdi(join(self.path, 'Copper.chik'), _larch=self._larch)

    gds = Group(amp    = Parameter(1,     vary=True),
                enot   = Parameter(1e-7,  vary=True),
                thetad = Parameter(500,   vary=True),
                temp   = Parameter(10,    vary=False),
                alpha  = Parameter(1e-7,  vary=True),
                ss1    = Parameter(0.003, vary=True),
                _larch=self._larch  )

    paths = list()
    for index in range(1,14):
        nnnn = realpath(join(folder, "feff%4.4d.dat" % index))
        if not exists(nnnn):
            continue
        #end if
        if index > 1:
            sigsqr = 'sigma2_debye(temp, thetad)' 
        else:
            sigsqr = 'ss1'
        #end if
        paths.append(feffpath(nnnn,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = sigsqr,
                              deltar = 'alpha*reff', _larch=self._larch))
    #end for

    trans = feffit_transform(kmin=3, kmax=16, kw=(2,1,3), dk=1, window='hanning', rmin=1.7, rmax=5.1, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8, win=2,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', win=2, _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', win=2, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', win=2, _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #2
0
def do_fit(self, which):

    if which == "testrun":
        folder = self.testrun
    else:
        folder = self.baseline

    data = read_xdi(join(self.path, "UO2.chik"), _larch=self._larch)

    gds = Group(
        amp=Parameter(1, vary=True, _larch=self._larch),
        enot=Parameter(0.01, vary=True, _larch=self._larch),
        sso=Parameter(0.003, vary=True, _larch=self._larch),
        ssu=Parameter(0.003, vary=True, _larch=self._larch),
        sso2=Parameter(0.003, vary=True, _larch=self._larch),
        dro=Parameter(0.0001, vary=True, _larch=self._larch),
        dru=Parameter(0.0001, vary=True, _larch=self._larch),
        dro2=Parameter(0.0001, vary=True, _larch=self._larch),
        nu=Parameter(12, vary=True, _larch=self._larch),
        no2=Parameter(expr="2*nu", _larch=self._larch),
        _larch=self._larch,
    )

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # 1st shell O SS
            s02="amp",
            e0="enot",
            sigma2="sso",
            deltar="dro",
            _larch=self._larch,
        )
    )
    # paths.append(feffpath(realpath(join(folder, "feff0002.dat")), # triangle in first shell
    #                       s02    = 'amp',
    #                       e0     = 'enot',
    #                       sigma2 = 'sso*1.5',
    #                       deltar = 'dro*(1+sqrt(2))/2', _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0003.dat")),  # 2nd shell U SS
            degen=1,
            s02="amp*nu",
            e0="enot",
            sigma2="ssu",
            deltar="dru",
            _larch=self._larch,
        )
    )
    # paths.append(feffpath(realpath(join(folder, "feff0004.dat")), # 1st shell, longer triangle
    #                       s02    = 'amp',
    #                       e0     = 'enot',
    #                       sigma2 = '2*sso',
    #                       deltar = '2*dro', _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0006.dat")),  # 3rd shell O SS
            degen=1,
            s02="amp*no2",
            # s02    = 'amp*nu*2',
            e0="enot",
            sigma2="sso2",
            deltar="dro2",
            _larch=self._larch,
        )
    )
    paths.append(
        feffpath(
            realpath(join(folder, "feff0007.dat")),  # 1st shell, non-forward linear through absorber
            s02="amp",
            e0="enot",
            sigma2="sso2",
            deltar="dro2",
            _larch=self._larch,
        )
    )
    paths.append(
        feffpath(
            realpath(join(folder, "feff0008.dat")),  # 1st shell forward through absorber
            s02="amp",
            e0="enot",
            sigma2="2*sso",
            deltar="2*dro",
            _larch=self._larch,
        )
    )
    paths.append(
        feffpath(
            realpath(join(folder, "feff0009.dat")),  # rattle in 1st shell
            s02="amp",
            e0="enot",
            sigma2="2*sso",
            deltar="2*dro",
            _larch=self._larch,
        )
    )

    trans = feffit_transform(
        kmin=3, kmax=11, kw=(2, 1, 3), dk=1, window="hanning", rmin=1.25, rmax=4.3, _larch=self._larch
    )
    dset = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(
            dset.data.r,
            dset.data.chir_mag + offset,
            xmax=8,
            win=2,
            xlabel=r"$R \rm\,(\AA)$",
            label="data",
            ylabel=r"$|\chi(R)| \rm\,(\AA^{-3})$",
            title="Fit to " + self.folder,
            show_legend=True,
            _larch=self._larch,
        )
        _plot(dset.model.r, dset.model.chir_mag + offset, label="fit", win=2, _larch=self._larch)
        _plot(dset.data.r, dset.data.chir_re, label="data", win=2, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label="fit", win=2, _larch=self._larch)
    # end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    # end if

    return fit
예제 #3
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    else:
        folder = self.baseline
    #end if

    data = read_xdi(join(self.path, 'bromoadamantane.chik'), _larch=self._larch)

    gds = Group(amp     = Parameter(1.021,     vary=False, _larch=self._larch),
                enot    = Parameter(4.01,      vary=True,  _larch=self._larch),
                delr    = Parameter(-0.007,    vary=True,  _larch=self._larch),
                brc     = Parameter(expr = '1.9521+delr',  _larch=self._larch),
                ss      = Parameter(0.003,     vary=True,  _larch=self._larch),
                phir    = Parameter(109.29960 * 3.141592653589793 / 180,   vary=False, _larch=self._larch),
                cc      = Parameter(1.53780,   vary=False, _larch=self._larch),
                tanbeta = Parameter(expr = '(brc+cc)*tan(phir/2) / (brc-cc)', _larch=self._larch),
                beta    = Parameter(expr = 'atan(tanbeta)', _larch=self._larch),
                brc2    = Parameter(expr = '(brc-cc)*cos(phir/2)/cos(beta)', _larch=self._larch),
                drh     = Parameter(0.04,      vary=True,  _larch=self._larch),
                ssh     = Parameter(0.005,     vary=True,  _larch=self._larch),
                ss2     = Parameter(expr = 'ss*(brc2/brc)**2', _larch=self._larch),
                c3      = Parameter(-0.0007,   vary=True,  _larch=self._larch),
                _larch=self._larch  )

    paths = list()
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ss',
                          deltar = 'delr',
                          third  = 'c3', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0002.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ss2',
                          deltar = 'brc2-2.8565', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0003.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ssh',
                          deltar = 'drh', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0004.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = '(ss+ss2)/2',
                          deltar = '(brc+brc2+cc)/2 - 3.173', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0005.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = '(ss+ss2)/2',
                          deltar = '(brc+brc2+cc)/2 - 3.173', _larch=self._larch))


    trans = feffit_transform(kmin=3, kmax=13, kw=(2,1,3), dk=1, window='hanning', rmin=1.25, rmax=3, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8, win=2,
                 xlabel=r'$R \rm\,(\AA)$', label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', win=2, _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', win=2, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', win=2, _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #4
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'Copper.chik'), _larch=self._larch)

    gds = Group(amp    = Parameter(1,     vary=True,  _larch=self._larch),
                enot   = Parameter(1e-7,  vary=True,  _larch=self._larch),
                ss1    = Parameter(0.003, vary=True,  _larch=self._larch), _larch=self._larch  )

    if firstshell:
        gds.delr   = Parameter(1e-7,   vary=True, _larch=self._larch)
        dr1param   = 'delr'
    else:
        gds.thetad = Parameter(500,   vary=True,  _larch=self._larch)
        gds.temp   = Parameter(10,    vary=False, _larch=self._larch)
        gds.alpha  = Parameter(1e-7,  vary=True,  _larch=self._larch)
        dr1param   = 'alpha*reff'

    imax = 16
    if firstshell: imax = 2
    paths = list()
    for index in range(1,imax):
        nnnn = realpath(join(folder, "feff%4.4d.dat" % index))
        if not exists(nnnn):
            continue
        #end if
        if index > 1:
            sigsqr = 'sigma2_debye(temp, thetad)' 
        else:
            sigsqr = 'ss1'
        #end if
        paths.append(feffpath(nnnn,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = sigsqr,
                              deltar = dr1param, _larch=self._larch))
    #end for

    rx  = 5.0
    if firstshell: rx  = 2.8

    trans = feffit_transform(kmin=3, kmax=15, kw=(2,1,3), dk=1, window='hanning', rmin=1, rmax=rx, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_'+which+shells+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'Copper',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 15,
                                         'rmin': 1,
                                         'rmax': rx,
                                         'offset': 2,
                                     } ))

    return fit
예제 #5
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    dmt = read_xdi(join(self.path, 'dmt.chik'), _larch=self._larch)
    mmt = read_xdi(join(self.path, 'mmt.chik'), _larch=self._larch)

    gds = Group(amp=Parameter(0.9, vary=True, _larch=self._larch),
                enot=Parameter(1e-7, vary=True, _larch=self._larch),
                delr_c=Parameter(1e-7, vary=True, _larch=self._larch),
                ss_c=Parameter(0.003, vary=True, _larch=self._larch),
                delr_cl=Parameter(1e-7, vary=True, _larch=self._larch),
                ss_cl=Parameter(0.003, vary=True, _larch=self._larch),
                _larch=self._larch)

    paths_dmt = list()
    paths_dmt.append(
        feffpath(realpath(join(folder, "feff0001.dat")),
                 degen=2,
                 s02='amp',
                 e0='enot',
                 sigma2='ss_c',
                 deltar='delr_c',
                 _larch=self._larch))
    paths_dmt.append(
        feffpath(realpath(join(folder, "feff0002.dat")),
                 degen=2,
                 s02='amp',
                 e0='enot',
                 sigma2='ss_cl',
                 deltar='delr_cl',
                 _larch=self._larch))
    paths_mmt = list()
    paths_mmt.append(
        feffpath(realpath(join(folder, "feff0001.dat")),
                 degen=1,
                 s02='amp',
                 e0='enot',
                 sigma2='ss_c',
                 deltar='delr_c',
                 _larch=self._larch))
    paths_mmt.append(
        feffpath(realpath(join(folder, "feff0002.dat")),
                 degen=3,
                 s02='amp',
                 e0='enot',
                 sigma2='ss_cl',
                 deltar='delr_cl',
                 _larch=self._larch))

    trans = feffit_transform(kmin=3,
                             kmax=13,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.25,
                             rmax=3,
                             _larch=self._larch)
    dset = [
        feffit_dataset(data=dmt,
                       pathlist=paths_dmt,
                       transform=trans,
                       _larch=self._larch),
        feffit_dataset(data=mmt,
                       pathlist=paths_mmt,
                       transform=trans,
                       _larch=self._larch)
    ]
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset[0].data.chir_mag) / 2
        _newplot(dset[0].data.r,
                 dset[0].data.chir_mag + offset,
                 xmax=5,
                 win=1,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='dimethyltin',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset[0].model.r,
              dset[0].model.chir_mag + offset,
              label='fit',
              win=1,
              _larch=self._larch)
        _plot(dset[0].data.r,
              dset[0].data.chir_re,
              label='dimethyltin',
              win=1,
              _larch=self._larch)
        _plot(dset[0].model.r,
              dset[0].model.chir_re,
              label='fit',
              win=1,
              _larch=self._larch)

        _plot(dset[1].data.r,
              dset[1].data.chir_mag + 7 * offset,
              label='monomethyltin',
              win=1,
              _larch=self._larch)
        _plot(dset[1].model.r,
              dset[1].model.chir_mag + 7 * offset,
              label='fit',
              win=1,
              _larch=self._larch)
        _plot(dset[1].data.r,
              dset[1].data.chir_re + 6 * offset,
              label='monomethyltin',
              win=1,
              _larch=self._larch)
        _plot(dset[1].model.r,
              dset[1].model.chir_re + 6 * offset,
              label='fit',
              win=1,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells = '_1st'

    write_ascii(join(self.folder, fittest, "fit_" + which + ".k"),
                dset.data[0].k,
                dset.data[0].chi,
                dset.model[0].chi,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_" + which + ".r"),
                dset.data[0].r,
                dset.data[0].chir_mag,
                dset.model[0].chir_mag,
                dset.data[0].chir_re,
                dset.model[0].chir_re,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_' + which + '.gp'), 'w') as inp:
        inp.write(
            renderer.render_path(
                'plot.mustache',  # gnuplot mustache file
                {
                    'material': 'methyltin',
                    'model': which,
                    'fittest': fittest,
                    'shells': shells,
                    'kmin': 3,
                    'kmax': 13,
                    'rmin': 1.25,
                    'rmax': 3,
                    'offset': 1,
                }))

    return fit
예제 #6
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    else:
        folder = self.baseline
    #end if

    data = read_xdi(join(self.path, 'bromoadamantane.chik'),
                    _larch=self._larch)

    gds = Group(amp=Parameter(1.021, vary=True, _larch=self._larch),
                enot=Parameter(4.01, vary=True, _larch=self._larch),
                delr=Parameter(-0.007, vary=True, _larch=self._larch),
                brc=Parameter(expr='1.9521+delr', _larch=self._larch),
                ss=Parameter(0.003, vary=True, _larch=self._larch),
                phir=Parameter(109.29960 * 3.141592653589793 / 180,
                               vary=False,
                               _larch=self._larch),
                cc=Parameter(1.53780, vary=False, _larch=self._larch),
                tanbeta=Parameter(expr='(brc+cc)*tan(phir/2) / (brc-cc)',
                                  _larch=self._larch),
                beta=Parameter(expr='atan(tanbeta)', _larch=self._larch),
                brc2=Parameter(expr='(brc-cc)*cos(phir/2)/cos(beta)',
                               _larch=self._larch),
                drh=Parameter(0.04, vary=True, _larch=self._larch),
                ssh=Parameter(0.005, vary=True, _larch=self._larch),
                ss2=Parameter(expr='ss*(brc2/brc)**2', _larch=self._larch),
                c3=Parameter(-0.0007, vary=True, _larch=self._larch),
                _larch=self._larch)

    paths = list()
    paths.append(
        feffpath(realpath(join(folder, "feff0001.dat")),
                 s02='amp',
                 e0='enot',
                 sigma2='ss',
                 deltar='delr',
                 third='c3',
                 _larch=self._larch))
    paths.append(
        feffpath(realpath(join(folder, "feff0002.dat")),
                 s02='amp',
                 e0='enot',
                 sigma2='ss2',
                 deltar='brc2-2.8565',
                 _larch=self._larch))
    paths.append(
        feffpath(realpath(join(folder, "feff0003.dat")),
                 s02='amp',
                 e0='enot',
                 sigma2='ssh',
                 deltar='drh',
                 _larch=self._larch))
    paths.append(
        feffpath(realpath(join(folder, "feff0004.dat")),
                 s02='amp',
                 e0='enot',
                 sigma2='(ss+ss2)/2',
                 deltar='(brc+brc2+cc)/2 - 3.173',
                 _larch=self._larch))
    paths.append(
        feffpath(realpath(join(folder, "feff0005.dat")),
                 s02='amp',
                 e0='enot',
                 sigma2='(ss+ss2)/2',
                 deltar='(brc+brc2+cc)/2 - 3.173',
                 _larch=self._larch))

    trans = feffit_transform(kmin=2.5,
                             kmax=13,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.25,
                             rmax=3,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 win=2,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              win=2,
              _larch=self._larch)
        _plot(dset.data.r,
              dset.data.chir_re,
              label='data',
              win=2,
              _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              win=2,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #7
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    else:
        folder = self.baseline

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber

    gds = Group(
        amp=Parameter(1, vary=True, _larch=self._larch),
        enot=Parameter(0.01, vary=True, _larch=self._larch),
        alpha=Parameter(0.0001, vary=True, _larch=self._larch),
        sso=Parameter(0.003, vary=True, _larch=self._larch),
        ssni=Parameter(0.003, vary=True, _larch=self._larch),
        sso2=Parameter(0.003, vary=True, _larch=self._larch),
        #sso3   = Parameter(0.003,  vary=True, _larch=self._larch),
        ssni2=Parameter(0.003, vary=True, _larch=self._larch),
        #ssni3  = Parameter(0.003,  vary=True, _larch=self._larch),
        #ssni4  = Parameter(0.003,  vary=True, _larch=self._larch),
        _larch=self._larch)

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # 1st shell O SS
            s02='amp',
            e0='enot',
            sigma2='sso',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0002.dat")),  # 2nd shell Ni SS
            s02='amp',
            e0='enot',
            sigma2='ssni',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0003.dat")),  # O-O triangle
            s02='amp',
            e0='enot',
            sigma2='1.5*sso',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0004.dat")),  # O-Ni triangle
            s02='amp',
            e0='enot',
            sigma2='sso+ssni',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0005.dat")),  # 3rd shell O SS
            s02='amp',
            e0='enot',
            sigma2='sso2',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0006.dat")),  # 4th shell Ni SS
            s02='amp',
            e0='enot',
            sigma2='ssni2',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0007.dat")),  # O-O non-forward linear
            s02='amp',
            e0='enot',
            sigma2='sso*2',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0008.dat")),  # O-Ni forward scattering
            s02='amp',
            e0='enot',
            sigma2='ssni2',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder,
                          "feff0009.dat")),  # O-O forward through absorber
            s02='amp',
            e0='enot',
            sigma2='sso*2',
            deltar='alpha*reff',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0010.dat")),  # O-Ni-O double forward
            s02='amp',
            e0='enot',
            sigma2='ssni2',
            deltar='alpha*reff',
            _larch=self._larch))

    trans = feffit_transform(kmin=3,
                             kmax=15.938,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.5,
                             rmax=4.2,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = 0.6 * max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 win=2,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              win=2,
              _larch=self._larch)
        _plot(dset.data.r,
              dset.data.chir_re,
              label='data',
              win=2,
              _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              win=2,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #8
0
파일: NiO.py 프로젝트: bruceravel/SCFtests
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber

    gds = Group(amp    = Parameter(1,      vary=True, _larch=self._larch),
                enot   = Parameter(1e-7,   vary=True, _larch=self._larch),
                sso    = Parameter(0.003,  vary=True, _larch=self._larch), _larch=self._larch  )

    if firstshell:
        gds.delr   = Parameter(1e-7,   vary=True, _larch=self._larch)
        dr1param   = 'delr'
    else:
        gds.alpha  = Parameter(1e-7,   vary=True, _larch=self._larch)
        gds.ssni   = Parameter(0.003,  vary=True, _larch=self._larch)
        gds.sso2   = Parameter(0.003,  vary=True, _larch=self._larch)
        #gds.sso3   = Parameter(0.003,  vary=True, _larch=self._larch)
        gds.ssni2  = Parameter(0.003,  vary=True, _larch=self._larch)
        #gds.ssni3  = Parameter(0.003,  vary=True, _larch=self._larch)
        #gds.ssni4  = Parameter(0.003,  vary=True, _larch=self._larch)
        dr1param   = 'alpha*reff'

    paths = list() 
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")), # 1st shell O SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso',
                          deltar = dr1param, _larch=self._larch))
    if not firstshell:
        paths.append(feffpath(realpath(join(folder, "feff0002.dat")), # 2nd shell Ni SS
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ssni',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0003.dat")), # O-O triangle
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '1.5*sso',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0004.dat")), # O-Ni triangle
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'sso+ssni/2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0005.dat")), # 3rd shell O SS
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'sso2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0006.dat")), # 4th shell Ni SS
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ssni2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0007.dat")), # O-O non-forward linear
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'sso*2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0008.dat")), # O-Ni forward scattering
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ssni2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0009.dat")), # O-O forward through absorber
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'sso*2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0011.dat")), # O-Ni-O double forward
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ssni2',
                              deltar = 'alpha*reff', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0010.dat")), # O-O rattle (the order of 10 and 11 is different in Demeter's pathfinder!)
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'sso*4',
                              deltar = 'alpha*reff', _larch=self._larch))

    rx  = 4.2
    if firstshell: rx  = 1.95

    trans = feffit_transform(kmin=3, kmax=15.938, kw=(2,1,3), dk=1, window='hanning', rmin=1.0, rmax=rx, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = 0.6*max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest,'fit_'+which+shells+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'NiO',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 15.938,
                                         'rmin': 1.0,
                                         'rmax': rx,
                                         'offset': 1,
                                     } ))

    return fit
예제 #9
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'UO2.chik'), _larch=self._larch)

    gds = Group(amp    = Parameter(1,      vary=True, _larch=self._larch),
                enot   = Parameter(1e-7,   vary=True, _larch=self._larch),
                sso    = Parameter(0.003,  vary=True, _larch=self._larch),
                dro    = Parameter(1e-7,   vary=True, _larch=self._larch), _larch=self._larch  )

    if not firstshell:
        gds.ssu    = Parameter(0.003,  vary=True, _larch=self._larch)
        gds.sso2   = Parameter(0.003,  vary=True, _larch=self._larch)
        gds.dru    = Parameter(1e-7,   vary=True, _larch=self._larch)
        gds.dro2   = Parameter(1e-7,   vary=True, _larch=self._larch)
        gds.nu     = Parameter(12,     vary=True, _larch=self._larch)
        gds.no2    = Parameter(expr='2*nu',       _larch=self._larch)

    paths = list() 
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")), # 1st shell O SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso',
                          deltar = 'dro', _larch=self._larch))

    if not firstshell:
        # paths.append(feffpath(realpath(join(folder, "feff0002.dat")), # triangle in first shell
        #                       s02    = 'amp',
        #                       e0     = 'enot',
        #                       sigma2 = 'sso*(1+sqrt(3))**2',
        #                       deltar = 'dro*(1+sqrt(3))/2', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0003.dat")), # 2nd shell U SS
                              degen  = 1,
                              s02    = 'amp*nu',
                              e0     = 'enot',
                              sigma2 = 'ssu',
                              deltar = 'dru', _larch=self._larch))
        # paths.append(feffpath(realpath(join(folder, "feff0004.dat")), # 1st shell, longer triangle
        #                       s02    = 'amp',
        #                       e0     = 'enot',
        #                       sigma2 = 'sso*(1+sqrt(2/3))**2',
        #                       deltar = '(1+sqrt(2/3))*dro', _larch=self._larch))
        # paths.append(feffpath(realpath(join(folder, "feff0005.dat")), # 1st shell, longer U-O-U triangle
        #                       degen  = 1,
        #                       s02    = 'amp*nu',
        #                       e0     = 'enot',
        #                       sigma2 = 'sso*ssu/2',
        #                       deltar = '(1+sqrt(2/3))*dro', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0006.dat")), # 3rd shell O SS
                              degen  = 1,
                              s02    = 'amp*no2',
                              e0     = 'enot',
                              sigma2 = 'sso2',
                              deltar = 'dro2', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0007.dat")), # 1st shell, non-forward linear through absorber
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '2*sso2',
                              deltar = '2*dro2', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0008.dat")), # 1st shell forward through absorber
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '2*sso',
                              deltar = '2*dro', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0009.dat")), # rattle in 1st shell
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '2*sso',
                              deltar = '2*dro', _larch=self._larch))

    rx  = 4.3
    if firstshell: rx  = 2.5

    trans = feffit_transform(kmin=3, kmax=11, kw=(2,1,3), dk=1, window='hanning', rmin=1.25, rmax=rx, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_'+which+shells+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'UO2',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 11,
                                         'rmin': 1.25,
                                         'rmax': rx,
                                         'offset': 0.75,
                                     } ))

    return fit
예제 #10
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    firstshell = False          # no 1st shell fit for this material

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'uranyl.chik'), _larch=self._larch)

    gds = Group(amp    = Parameter(1,      vary=True,  _larch=self._larch),
                enot   = Parameter(1e-7,   vary=True,  _larch=self._larch),
                #enot   = Parameter(1e-7,   vary=True,  _larch=self._larch, min=0, max=13),
                enoteq = Parameter(expr= 'enot',     _larch=self._larch),
                deloax = Parameter(1e-7,   vary=True,  _larch=self._larch),
                deloeq = Parameter(1e-7,   vary=True,  _larch=self._larch),
                sigoax = Parameter(0.003,  vary=True,  _larch=self._larch),
                sigoeq = Parameter(0.003,  vary=True,  _larch=self._larch),
                nax    = Parameter(2.0,    vary=False, _larch=self._larch),
                neq    = Parameter(6,      vary=False, _larch=self._larch), #, min=0, max=12),
                _larch=self._larch  )

    paths = list() 
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")), # axial oxygen
                          degen  = 1,
                          s02    = 'amp*nax',
                          e0     = 'enot',
                          sigma2 = 'sigoax',
                          deltar = 'deloax', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0003.dat")), # equatorial oxygen
                          degen  = 1,
                          s02    = 'amp*neq',
                          e0     = 'enoteq',
                          sigma2 = 'sigoeq',
                          deltar = 'deloeq', _larch=self._larch))

    paths.append(feffpath(realpath(join(folder, "feff0008.dat")), # axial oxygen, rattle
                          degen  = 1,
                          s02    = 'amp*nax',
                          e0     = 'enot',
                          sigma2 = 'sigoax*4',
                          deltar = 'deloax*2', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0009.dat")), # axial oxygen, non-forward
                          degen  = 1,
                          s02    = 'amp*nax',
                          e0     = 'enot',
                          sigma2 = 'sigoax',
                          deltar = 'deloax*2', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0010.dat")), # axial oxygen, forward
                          degen  = 1,
                          s02    = 'amp*nax',
                          e0     = 'enot',
                          sigma2 = 'sigoax',
                          deltar = 'deloax*2', _larch=self._larch))




    trans = feffit_transform(kmin=3, kmax=11, kw=(2,1,3), dk=1, window='hanning', rmin=1.0, rmax=3.2, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8, win=2,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', win=2, _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', win=2, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', win=2, _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_'+which+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'uranyl',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 11,
                                         'rmin': 1.0,
                                         'rmax': 3.2,
                                         'offset': 1,
                                     } ))

    return fit
예제 #11
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    dmt = read_xdi(join(self.path, 'dmt.chik'), _larch=self._larch)
    mmt = read_xdi(join(self.path, 'mmt.chik'), _larch=self._larch)

    gds = Group(amp     = Parameter(0.9,       vary=True,  _larch=self._larch),
                enot    = Parameter(1e-7,      vary=True,  _larch=self._larch),
                delr_c  = Parameter(1e-7,      vary=True,  _larch=self._larch),
                ss_c    = Parameter(0.003,     vary=True,  _larch=self._larch),
                delr_cl = Parameter(1e-7,      vary=True,  _larch=self._larch),
                ss_cl   = Parameter(0.003,     vary=True,  _larch=self._larch),
                _larch=self._larch  )

    paths_dmt = list()
    paths_dmt.append(feffpath(realpath(join(folder, "feff0001.dat")),
                              degen  = 2,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ss_c',
                              deltar = 'delr_c', _larch=self._larch))
    paths_dmt.append(feffpath(realpath(join(folder, "feff0002.dat")),
                              degen  = 2,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ss_cl',
                              deltar = 'delr_cl', _larch=self._larch))
    paths_mmt = list()
    paths_mmt.append(feffpath(realpath(join(folder, "feff0001.dat")),
                              degen  = 1,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ss_c',
                              deltar = 'delr_c', _larch=self._larch))
    paths_mmt.append(feffpath(realpath(join(folder, "feff0002.dat")),
                              degen  = 3,
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ss_cl',
                              deltar = 'delr_cl', _larch=self._larch))


    trans = feffit_transform(kmin=3, kmax=13, kw=(2,1,3), dk=1, window='hanning', rmin=1.25, rmax=3, _larch=self._larch)
    dset  = [feffit_dataset(data=dmt, pathlist=paths_dmt, transform=trans, _larch=self._larch),
             feffit_dataset(data=mmt, pathlist=paths_mmt, transform=trans, _larch=self._larch)]
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset[0].data.chir_mag)/2
        _newplot(dset[0].data.r,  dset[0].data.chir_mag+offset, xmax=5, win=1,
                 xlabel=r'$R \rm\,(\AA)$', label='dimethyltin',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset[0].model.r, dset[0].model.chir_mag+offset,   label='fit',  win=1, _larch=self._larch)
        _plot(dset[0].data.r,  dset[0].data.chir_re,            label='dimethyltin', win=1, _larch=self._larch)
        _plot(dset[0].model.r, dset[0].model.chir_re,           label='fit',  win=1, _larch=self._larch)

        _plot(dset[1].data.r,  dset[1].data.chir_mag+7*offset,  label='monomethyltin', win=1, _larch=self._larch)
        _plot(dset[1].model.r, dset[1].model.chir_mag+7*offset, label='fit',  win=1, _larch=self._larch)
        _plot(dset[1].data.r,  dset[1].data.chir_re+6*offset,   label='monomethyltin', win=1, _larch=self._larch)
        _plot(dset[1].model.r, dset[1].model.chir_re+6*offset,  label='fit',  win=1, _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+".k"), dset.data[0].k, dset.data[0].chi, dset.model[0].chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+".r"), dset.data[0].r, dset.data[0].chir_mag, dset.model[0].chir_mag,
                dset.data[0].chir_re, dset.model[0].chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_'+which+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'methyltin',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 13,
                                         'rmin': 1.25,
                                         'rmax': 3,
                                         'offset': 1,
                                     } ))

    return fit
예제 #12
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    else:
        folder = self.baseline

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber

    gds = Group(amp    = Parameter(1,      vary=True, _larch=self._larch),
                enot   = Parameter(0.01,   vary=True, _larch=self._larch),
                alpha  = Parameter(0.0001, vary=True, _larch=self._larch),
                sso    = Parameter(0.003,  vary=True, _larch=self._larch),
                ssni   = Parameter(0.003,  vary=True, _larch=self._larch),
                sso2   = Parameter(0.003,  vary=True, _larch=self._larch),
                #sso3   = Parameter(0.003,  vary=True, _larch=self._larch),
                ssni2  = Parameter(0.003,  vary=True, _larch=self._larch),
                #ssni3  = Parameter(0.003,  vary=True, _larch=self._larch),
                #ssni4  = Parameter(0.003,  vary=True, _larch=self._larch),
                _larch=self._larch  )

    paths = list() 
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")), # 1st shell O SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0002.dat")), # 2nd shell Ni SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ssni',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0003.dat")), # O-O triangle
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = '1.5*sso',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0004.dat")), # O-Ni triangle
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso+ssni',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0005.dat")), # 3rd shell O SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso2',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0006.dat")), # 4th shell Ni SS
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ssni2',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0007.dat")), # O-O non-forward linear
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso*2',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0008.dat")), # O-Ni forward scattering
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ssni2',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0009.dat")), # O-O forward through absorber
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'sso*2',
                          deltar = 'alpha*reff', _larch=self._larch))
    paths.append(feffpath(realpath(join(folder, "feff0010.dat")), # O-Ni-O double forward
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ssni2',
                          deltar = 'alpha*reff', _larch=self._larch))


    trans = feffit_transform(kmin=3, kmax=15.938, kw=(2,1,3), dk=1, window='hanning', rmin=1.5, rmax=4.2, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = 0.6*max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8, win=2,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', win=2, _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', win=2, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', win=2, _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #13
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    else:
        folder = self.baseline

    data = read_xdi(join(self.path, 'UO2.chik'), _larch=self._larch)

    gds = Group(amp=Parameter(1, vary=True, _larch=self._larch),
                enot=Parameter(0.01, vary=True, _larch=self._larch),
                sso=Parameter(0.003, vary=True, _larch=self._larch),
                ssu=Parameter(0.003, vary=True, _larch=self._larch),
                sso2=Parameter(0.003, vary=True, _larch=self._larch),
                dro=Parameter(0.0001, vary=True, _larch=self._larch),
                dru=Parameter(0.0001, vary=True, _larch=self._larch),
                dro2=Parameter(0.0001, vary=True, _larch=self._larch),
                nu=Parameter(12, vary=True, _larch=self._larch),
                no2=Parameter(expr='2*nu', _larch=self._larch),
                _larch=self._larch)

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # 1st shell O SS
            s02='amp',
            e0='enot',
            sigma2='sso',
            deltar='dro',
            _larch=self._larch))
    # paths.append(feffpath(realpath(join(folder, "feff0002.dat")), # triangle in first shell
    #                       s02    = 'amp',
    #                       e0     = 'enot',
    #                       sigma2 = 'sso*1.5',
    #                       deltar = 'dro*(1+sqrt(2))/2', _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0003.dat")),  # 2nd shell U SS
            degen=1,
            s02='amp*nu',
            e0='enot',
            sigma2='ssu',
            deltar='dru',
            _larch=self._larch))
    # paths.append(feffpath(realpath(join(folder, "feff0004.dat")), # 1st shell, longer triangle
    #                       s02    = 'amp',
    #                       e0     = 'enot',
    #                       sigma2 = '2*sso',
    #                       deltar = '2*dro', _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0006.dat")),  # 3rd shell O SS
            degen=1,
            s02='amp*no2',
            #s02    = 'amp*nu*2',
            e0='enot',
            sigma2='sso2',
            deltar='dro2',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0007.dat")
                     ),  # 1st shell, non-forward linear through absorber
            s02='amp',
            e0='enot',
            sigma2='sso2',
            deltar='dro2',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(
                folder, "feff0008.dat")),  # 1st shell forward through absorber
            s02='amp',
            e0='enot',
            sigma2='2*sso',
            deltar='2*dro',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0009.dat")),  # rattle in 1st shell
            s02='amp',
            e0='enot',
            sigma2='2*sso',
            deltar='2*dro',
            _larch=self._larch))

    trans = feffit_transform(kmin=3,
                             kmax=11,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.25,
                             rmax=4.3,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 win=2,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              win=2,
              _larch=self._larch)
        _plot(dset.data.r,
              dset.data.chir_re,
              label='data',
              win=2,
              _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              win=2,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #14
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    firstshell = False  # no 1st shell fit for this material

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'uranyl.chik'), _larch=self._larch)

    gds = Group(
        amp=Parameter(1, vary=True, _larch=self._larch),
        enot=Parameter(1e-7, vary=True, _larch=self._larch),
        #enot   = Parameter(1e-7,   vary=True,  _larch=self._larch, min=0, max=13),
        enoteq=Parameter(expr='enot', _larch=self._larch),
        deloax=Parameter(1e-7, vary=True, _larch=self._larch),
        deloeq=Parameter(1e-7, vary=True, _larch=self._larch),
        sigoax=Parameter(0.003, vary=True, _larch=self._larch),
        sigoeq=Parameter(0.003, vary=True, _larch=self._larch),
        nax=Parameter(2.0, vary=False, _larch=self._larch),
        neq=Parameter(6, vary=False, _larch=self._larch),  #, min=0, max=12),
        _larch=self._larch)

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # axial oxygen
            degen=1,
            s02='amp*nax',
            e0='enot',
            sigma2='sigoax',
            deltar='deloax',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0003.dat")),  # equatorial oxygen
            degen=1,
            s02='amp*neq',
            e0='enoteq',
            sigma2='sigoeq',
            deltar='deloeq',
            _larch=self._larch))

    paths.append(
        feffpath(
            realpath(join(folder, "feff0008.dat")),  # axial oxygen, rattle
            degen=1,
            s02='amp*nax',
            e0='enot',
            sigma2='sigoax*4',
            deltar='deloax*2',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder,
                          "feff0009.dat")),  # axial oxygen, non-forward
            degen=1,
            s02='amp*nax',
            e0='enot',
            sigma2='sigoax',
            deltar='deloax*2',
            _larch=self._larch))
    paths.append(
        feffpath(
            realpath(join(folder, "feff0010.dat")),  # axial oxygen, forward
            degen=1,
            s02='amp*nax',
            e0='enot',
            sigma2='sigoax',
            deltar='deloax*2',
            _larch=self._larch))

    trans = feffit_transform(kmin=3,
                             kmax=11,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.0,
                             rmax=3.2,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 win=2,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              win=2,
              _larch=self._larch)
        _plot(dset.data.r,
              dset.data.chir_re,
              label='data',
              win=2,
              _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              win=2,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells = '_1st'

    write_ascii(join(self.folder, fittest, "fit_" + which + ".k"),
                dset.data.k,
                dset.data.chi,
                dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_" + which + ".r"),
                dset.data.r,
                dset.data.chir_mag,
                dset.model.chir_mag,
                dset.data.chir_re,
                dset.model.chir_re,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_' + which + '.gp'), 'w') as inp:
        inp.write(
            renderer.render_path(
                'plot.mustache',  # gnuplot mustache file
                {
                    'material': 'uranyl',
                    'model': which,
                    'fittest': fittest,
                    'shells': shells,
                    'kmin': 3,
                    'kmax': 11,
                    'rmin': 1.0,
                    'rmax': 3.2,
                    'offset': 1,
                }))

    return fit
예제 #15
0
def do_fit(self, which):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, 'baseline', which))
    #endif

    print '>>>>>> %s' % folder

    data = read_xdi(join(self.path, 'Copper.chik'), _larch=self._larch)

    gds = Group(amp=Parameter(1, vary=True),
                enot=Parameter(1e-7, vary=True),
                thetad=Parameter(500, vary=True),
                temp=Parameter(10, vary=False),
                alpha=Parameter(1e-7, vary=True),
                ss1=Parameter(0.003, vary=True),
                _larch=self._larch)

    paths = list()
    for index in range(1, 14):
        nnnn = realpath(join(folder, "feff%4.4d.dat" % index))
        if not exists(nnnn):
            continue
        #end if
        if index > 1:
            sigsqr = 'sigma2_debye(temp, thetad)'
        else:
            sigsqr = 'ss1'
        #end if
        paths.append(
            feffpath(nnnn,
                     s02='amp',
                     e0='enot',
                     sigma2=sigsqr,
                     deltar='alpha*reff',
                     _larch=self._larch))
    #end for

    trans = feffit_transform(kmin=3,
                             kmax=16,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.7,
                             rmax=5.1,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 win=2,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              win=2,
              _larch=self._larch)
        _plot(dset.data.r,
              dset.data.chir_re,
              label='data',
              win=2,
              _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              win=2,
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    return fit
예제 #16
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'bromoadamantane.chik'), _larch=self._larch)

    gds = Group(amp     = Parameter(0.9,       vary=True,  _larch=self._larch),
                enot    = Parameter(4.01,      vary=True,  _larch=self._larch),
                delr    = Parameter(1e-7  ,    vary=True,  units='AA',   decimals=3, _larch=self._larch),
                ss      = Parameter(0.003,     vary=True,  units='AA^2', _larch=self._larch),
                c3      = Parameter(1e-7,      vary=False, _larch=self._larch),
                _larch=self._larch  )
    if not firstshell:
        gds.brc     = Parameter(expr = '1.9521+delr',  units='AA',  _larch=self._larch)
        #gds.phir    = Parameter(109.29960 * 3.141592653589793 / 180,   vary=False, _larch=self._larch)
        gds.cc      = Parameter(1.53780,   vary=False, _larch=self._larch)
        #gds.tanbeta = Parameter(expr = '(brc+cc)*tan(phir/2) / (brc-cc)', _larch=self._larch)
        #gds.beta    = Parameter(expr = 'atan(tanbeta)', _larch=self._larch)
        #gds.brc2    = Parameter(expr = '(brc-cc)*cos(phir/2)/cos(beta)',  units='AA', _larch=self._larch)
        gds.drh     = Parameter(0.04,      vary=True,  units='AA', decimals=3, _larch=self._larch)
        gds.ssh     = Parameter(0.005,     vary=True,  units='AA^2', _larch=self._larch)
        gds.ss2     = Parameter(expr = 'ss*(brc2/brc)**2', units ='AA^2', _larch=self._larch)
        gds.drc     = Parameter(0.04,      vary=True,  units='AA', decimals=3, _larch=self._larch)
        gds.brc2    = Parameter(expr = '2.8565+drc',   units='AA', decimals=3, _larch=self._larch)
        
    paths = list()
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")),
                          s02    = 'amp',
                          e0     = 'enot',
                          sigma2 = 'ss',
                          deltar = 'delr',
                          third  = 'c3', _larch=self._larch))

    if not firstshell:
        paths.append(feffpath(realpath(join(folder, "feff0002.dat")),
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ss2',
                              #deltar = 'brc2-2.8565',
                              deltar = 'drc',_larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0003.dat")),
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = 'ssh',
                              deltar = 'drh', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0004.dat")),
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '(ss+ss2)/2',
                              deltar = '(brc+brc2+cc)/2 - 3.173', _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0005.dat")),
                              s02    = 'amp',
                              e0     = 'enot',
                              sigma2 = '(ss+ss2)/2',
                              deltar = '(brc+brc2+cc)/2 - 3.173', _larch=self._larch))

    rx  = 3
    if firstshell: rx  = 1.83

    trans = feffit_transform(kmin=3, kmax=11, kw=(2,1,3), dk=1, window='hanning', rmin=1, rmax=3, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8,
                 xlabel=r'$R \rm\,(\AA)$', label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest,'fit_'+which+shells+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'bromoadamantane',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 13,
                                         'rmin': 1,
                                         'rmax': rx,
                                         'offset': 0.2,
                                     } ))

    return fit
예제 #17
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'BaZrO3.chik'), _larch=self._larch)

    gds = Group(amp    = Parameter(0.95,    vary=True,  _larch=self._larch),
                enot   = Parameter(1e-7,    vary=True,  _larch=self._larch),
                sso    = Parameter(0.003,   vary=True,  _larch=self._larch),
                czr    = Parameter(0.,      vary=False, _larch=self._larch), _larch=self._larch  )

    if firstshell:
        gds.delr   = Parameter(1e-7,    vary=True,  _larch=self._larch)
        dr1param   = 'delr'
    else:
        gds.alpha  = Parameter(0.00001, vary=True,  _larch=self._larch)
        gds.ssba   = Parameter(0.003,   vary=True,  _larch=self._larch)
        gds.sszr   = Parameter(0.003,   vary=True,  _larch=self._larch)
        gds.eba    = Parameter(1e-7,    vary=True,  _larch=self._larch)
        gds.ezr    = Parameter(1e-7,    vary=True,  _larch=self._larch)
        #gds.eba    = Parameter(expr='enot',          _larch=self._larch)
        #gdsezr    = Parameter(expr='enot',         _larch=self._larch)
        gds.sso2   = Parameter(0.003,   vary=True,  _larch=self._larch)
        dr1param   = 'alpha*reff'

    paths = list()
    paths.append(feffpath(realpath(join(folder, "feff0001.dat")),
                          s02    = 'amp',
                          deltar = dr1param,
                          e0     = 'enot',
                          sigma2 = 'sso',
                          _larch=self._larch))
    if not firstshell:
        paths.append(feffpath(realpath(join(folder, "feff0002.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso*1.5',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0003.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'eba',
                              sigma2 = 'ssba',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0004.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'ezr',
                              sigma2 = 'sszr',
                              third  = 'czr',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0005.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso*2',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0006.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = '(enot+ezr)/2',
                              sigma2 = 'sszr',
                              third  = 'czr',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0007.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso*2',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0009.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = '(2*enot+ezr)/3',
                              sigma2 = 'sszr',
                              third  = 'czr',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0008.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso*4',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0011.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = '(enot+eba)/2',
                              sigma2 = 'ssba+sso',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0012.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso2',
                              _larch=self._larch))
        paths.append(feffpath(realpath(join(folder, "feff0013.dat")),
                              s02    = 'amp',
                              deltar = 'alpha*reff',
                              e0     = 'enot',
                              sigma2 = 'sso+sso2',
                              _larch=self._larch))

    rx  = 4.5
    if firstshell: rx  = 1.95

    trans = feffit_transform(kmin=3, kmax=14.5, kw=(2,1,3), dk=1, window='hanning', rmin=1.2, rmax=rx, _larch=self._larch)
    dset  = feffit_dataset(data=data, pathlist=paths, transform=trans, _larch=self._larch)
    fit   = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,  dset.data.chir_mag+offset, xmax=8,
              xlabel=r'$R \rm\,(\AA)$', label='data',
              ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
              title='Fit to '+self.folder, show_legend=True, _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_mag+offset, label='fit', _larch=self._larch)
        _plot(dset.data.r,  dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r, dset.model.chir_re, label='fit', _larch=self._larch)
    #end if
    
    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells='_1st'

    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".k"), dset.data.k, dset.data.chi, dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_"+which+shells+".r"), dset.data.r, dset.data.chir_mag, dset.model.chir_mag,
                dset.data.chir_re, dset.model.chir_re, labels="r data_mag fit_mag data_re fit_re", _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_'+which+shells+'.gp'), 'w') as inp:
        inp.write(renderer.render_path( 'plot.mustache', # gnuplot mustache file
                                        {'material': 'BaZrO3',
                                         'model': which,
                                         'fittest': fittest,
                                         'shells': shells,
                                         'kmin': 3,
                                         'kmax': 14.5,
                                         'rmin': 1.2,
                                         'rmax': rx,
                                         'offset': 1,
                                     } ))

    return fit
예제 #18
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'Copper.chik'), _larch=self._larch)

    gds = Group(amp=Parameter(1, vary=True, _larch=self._larch),
                enot=Parameter(1e-7, vary=True, _larch=self._larch),
                ss1=Parameter(0.003, vary=True, _larch=self._larch),
                _larch=self._larch)

    if firstshell:
        gds.delr = Parameter(1e-7, vary=True, _larch=self._larch)
        dr1param = 'delr'
    else:
        gds.thetad = Parameter(500, vary=True, _larch=self._larch)
        gds.temp = Parameter(10, vary=False, _larch=self._larch)
        gds.alpha = Parameter(1e-7, vary=True, _larch=self._larch)
        dr1param = 'alpha*reff'

    imax = 16
    if firstshell: imax = 2
    paths = list()
    for index in range(1, imax):
        nnnn = realpath(join(folder, "feff%4.4d.dat" % index))
        if not exists(nnnn):
            continue
        #end if
        if index > 1:
            sigsqr = 'sigma2_debye(temp, thetad)'
        else:
            sigsqr = 'ss1'
        #end if
        paths.append(
            feffpath(nnnn,
                     s02='amp',
                     e0='enot',
                     sigma2=sigsqr,
                     deltar=dr1param,
                     _larch=self._larch))
    #end for

    rx = 5.0
    if firstshell: rx = 2.8

    trans = feffit_transform(kmin=3,
                             kmax=15,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1,
                             rmax=rx,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              _larch=self._larch)
        _plot(dset.data.r, dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells = '_1st'

    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".k"),
                dset.data.k,
                dset.data.chi,
                dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".r"),
                dset.data.r,
                dset.data.chir_mag,
                dset.model.chir_mag,
                dset.data.chir_re,
                dset.model.chir_re,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_' + which + shells + '.gp'),
              'w') as inp:
        inp.write(
            renderer.render_path(
                'plot.mustache',  # gnuplot mustache file
                {
                    'material': 'Copper',
                    'model': which,
                    'fittest': fittest,
                    'shells': shells,
                    'kmin': 3,
                    'kmax': 15,
                    'rmin': 1,
                    'rmax': rx,
                    'offset': 2,
                }))

    return fit
예제 #19
0
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber

    gds = Group(amp=Parameter(1, vary=True, _larch=self._larch),
                enot=Parameter(1e-7, vary=True, _larch=self._larch),
                sso=Parameter(0.003, vary=True, _larch=self._larch),
                _larch=self._larch)

    if firstshell:
        gds.delr = Parameter(1e-7, vary=True, _larch=self._larch)
        dr1param = 'delr'
    else:
        gds.alpha = Parameter(1e-7, vary=True, _larch=self._larch)
        gds.ssni = Parameter(0.003, vary=True, _larch=self._larch)
        gds.sso2 = Parameter(0.003, vary=True, _larch=self._larch)
        #gds.sso3   = Parameter(0.003,  vary=True, _larch=self._larch)
        gds.ssni2 = Parameter(0.003, vary=True, _larch=self._larch)
        #gds.ssni3  = Parameter(0.003,  vary=True, _larch=self._larch)
        #gds.ssni4  = Parameter(0.003,  vary=True, _larch=self._larch)
        dr1param = 'alpha*reff'

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # 1st shell O SS
            s02='amp',
            e0='enot',
            sigma2='sso',
            deltar=dr1param,
            _larch=self._larch))
    if not firstshell:
        paths.append(
            feffpath(
                realpath(join(folder, "feff0002.dat")),  # 2nd shell Ni SS
                s02='amp',
                e0='enot',
                sigma2='ssni',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0003.dat")),  # O-O triangle
                s02='amp',
                e0='enot',
                sigma2='1.5*sso',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0004.dat")),  # O-Ni triangle
                s02='amp',
                e0='enot',
                sigma2='sso+ssni/2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0005.dat")),  # 3rd shell O SS
                s02='amp',
                e0='enot',
                sigma2='sso2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0006.dat")),  # 4th shell Ni SS
                s02='amp',
                e0='enot',
                sigma2='ssni2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0007.dat")),  # O-O non-forward linear
                s02='amp',
                e0='enot',
                sigma2='sso*2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0008.dat")),  # O-Ni forward scattering
                s02='amp',
                e0='enot',
                sigma2='ssni2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0009.dat")),  # O-O forward through absorber
                s02='amp',
                e0='enot',
                sigma2='sso*2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0011.dat")),  # O-Ni-O double forward
                s02='amp',
                e0='enot',
                sigma2='ssni2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(
                    join(folder, "feff0010.dat")
                ),  # O-O rattle (the order of 10 and 11 is different in Demeter's pathfinder!)
                s02='amp',
                e0='enot',
                sigma2='sso*4',
                deltar='alpha*reff',
                _larch=self._larch))

    rx = 4.2
    if firstshell: rx = 1.95

    trans = feffit_transform(kmin=3,
                             kmax=15.938,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.0,
                             rmax=rx,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = 0.6 * max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              _larch=self._larch)
        _plot(dset.data.r, dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells = '_1st'

    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".k"),
                dset.data.k,
                dset.data.chi,
                dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".r"),
                dset.data.r,
                dset.data.chir_mag,
                dset.model.chir_mag,
                dset.data.chir_re,
                dset.model.chir_re,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_' + which + shells + '.gp'),
              'w') as inp:
        inp.write(
            renderer.render_path(
                'plot.mustache',  # gnuplot mustache file
                {
                    'material': 'NiO',
                    'model': which,
                    'fittest': fittest,
                    'shells': shells,
                    'kmin': 3,
                    'kmax': 15.938,
                    'rmin': 1.0,
                    'rmax': rx,
                    'offset': 1,
                }))

    return fit
예제 #20
0
파일: FeS2.py 프로젝트: bruceravel/SCFtests
def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'FeS2.chik'), _larch=self._larch)

    gds = Group(amp=Parameter(1, vary=True, _larch=self._larch),
                enot=Parameter(1e-7, vary=True, _larch=self._larch),
                ss=Parameter(0.003, vary=True, _larch=self._larch),
                _larch=self._larch)

    if firstshell:
        gds.delr = Parameter(1e-7, vary=True, _larch=self._larch)
        dr1param = 'delr'
    else:
        gds.alpha = Parameter(1e-7, vary=True, _larch=self._larch)
        gds.ss2 = Parameter(0.003, vary=True, _larch=self._larch)
        gds.ss3 = Parameter(expr='ss2', _larch=self._larch)
        gds.ssfe = Parameter(0.003, vary=True, _larch=self._larch)
        dr1param = 'alpha*reff'

    paths = list()
    paths.append(
        feffpath(
            realpath(join(folder, "feff0001.dat")),  # 1st shell S SS
            s02='amp',
            e0='enot',
            sigma2='ss',
            deltar=dr1param,
            _larch=self._larch))
    if not firstshell:
        paths.append(
            feffpath(
                realpath(join(folder, "feff0002.dat")),  # 2nd shell S SS
                s02='amp',
                e0='enot',
                sigma2='ss2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0003.dat")),  # 3rd shell S SS
                s02='amp',
                e0='enot',
                sigma2='ss3',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0004.dat")),  # 4th shell Fe SS
                s02='amp',
                e0='enot',
                sigma2='ssfe',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0005.dat")),  # S-S triangle
                s02='amp',
                e0='enot',
                sigma2='ss*1.5',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0006.dat")),  # S-Fe triangle
                s02='amp',
                e0='enot',
                sigma2='ss/2+ssfe',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0012.dat")),  # S-S non-forward linear
                s02='amp',
                e0='enot',
                sigma2='ss*2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder,
                              "feff0013.dat")),  # S-S forward scattering
                s02='amp',
                e0='enot',
                sigma2='ss*2',
                deltar='alpha*reff',
                _larch=self._larch))
        paths.append(
            feffpath(
                realpath(join(folder, "feff0014.dat")),  # S-S rattle
                s02='amp',
                e0='enot',
                sigma2='ss*4',
                deltar='alpha*reff',
                _larch=self._larch))

    rx = 4.2
    if firstshell: rx = 2.3

    trans = feffit_transform(kmin=3,
                             kmax=12.956,
                             kw=(2, 1, 3),
                             dk=1,
                             window='hanning',
                             rmin=1.2,
                             rmax=rx,
                             _larch=self._larch)
    dset = feffit_dataset(data=data,
                          pathlist=paths,
                          transform=trans,
                          _larch=self._larch)
    fit = feffit(gds, dset, _larch=self._larch)

    if self.doplot:
        offset = 0.6 * max(dset.data.chir_mag)
        _newplot(dset.data.r,
                 dset.data.chir_mag + offset,
                 xmax=8,
                 xlabel=r'$R \rm\,(\AA)$',
                 label='data',
                 ylabel=r'$|\chi(R)| \rm\,(\AA^{-3})$',
                 title='Fit to ' + self.folder,
                 show_legend=True,
                 _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_mag + offset,
              label='fit',
              _larch=self._larch)
        _plot(dset.data.r, dset.data.chir_re, label='data', _larch=self._larch)
        _plot(dset.model.r,
              dset.model.chir_re,
              label='fit',
              _larch=self._larch)
    #end if

    if self.verbose:
        print feffit_report(fit, _larch=self._larch)
    #end if

    shells = ''
    if firstshell: shells = '_1st'

    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".k"),
                dset.data.k,
                dset.data.chi,
                dset.model.chi,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)
    write_ascii(join(self.folder, fittest, "fit_" + which + shells + ".r"),
                dset.data.r,
                dset.data.chir_mag,
                dset.model.chir_mag,
                dset.data.chir_re,
                dset.model.chir_re,
                labels="r data_mag fit_mag data_re fit_re",
                _larch=self._larch)

    renderer = pystache.Renderer()
    with open(join(self.folder, fittest, 'fit_' + which + shells + '.gp'),
              'w') as inp:
        inp.write(
            renderer.render_path(
                'plot.mustache',  # gnuplot mustache file
                {
                    'material': 'FeS2',
                    'model': which,
                    'fittest': fittest,
                    'shells': shells,
                    'kmin': 3,
                    'kmax': 12.956,
                    'rmin': 1.2,
                    'rmax': rx,
                    'offset': 1,
                }))

    return fit