[Ifeffit] restraints in larch

Matt Newville newville at cars.uchicago.edu
Fri Oct 5 08:00:07 CDT 2018


Hi Hanyu, Barbara,


On Fri, Oct 5, 2018 at 12:55 AM Hanyu Zhang <hxz269 at case.edu> wrote:

> Hi,
>
> Thought I'd give my two cents before the experts chime in... I'm only a
> grad student right now though so make what you want out of it. I also
> haven't touched Larch for a while now since I got my xafs (Larch) functions
> working in python several months ago.
>
> First off though, ntot1 = param(expr='nO1+nO2', min=5.0, max=8.5) ran
> without throwing an error in Larch for me... (See screenshot near the
> middle of this email) So I don't think anyone can really help without more
> details, but I want to comment on some things:
>
>    1. The first thing is that you're missing a vary = True in the
>    statement for ntot1. Since the default value for vary is False according
>    to the website, I would add that in if you actually wanted it to be fitted
>    for during the fitting process (
>    https://xraypy.github.io/xraylarch/fitting/parameters.html).
>    2. In addition, when you run ntot1 = param(expr='nO1+nO2', min=5.0,
>    max=8.5), are nO1 and nO2 pre-defined? If not the computer's not going
>    to know what to make of those variables.
>    3. I'd recommend something along the lines of:
>
> nO1 = param(7.0, min=5, max=7, vary=True)
> nO2 = param(1, vary=True),
> ntot1 = param(expr='nO1+nO2', min=5.0, max=8.5, vary=True)
>
> I just tested this on my machine and it didn't throw any errors. (Though
> it also didn't throw any errors without the 2 fixes I recommended...):
>
> [image: Screen Shot 2018-10-05 at 12.55.59 AM.png]
>
> I didn't think to check when I took that screenshot but with that line,
> the vary is in fact set to false:
>
> larch> ntot1.vary
>
> False
>
>
> In terms of the errors on error calculation --
>
>    1. What's the reduced chi-sq? What do you mean by very small? In
>    physics you want that to be as close to one as possible. Though in xafs the
>    reduced chi-sq apparently is typically around 100-1000 so I'm confused as
>    to what you mean by "small". Also, if you're having issues with errorbars
>    to begin with, I wouldn't trust the chi-sq since that calculation
>    relies on how big the errorbars are. If the errors are NAN, who knows
>    what the computer would do to divide those numbers...
>    2. What do you mean by "errors are not reported"? After the fit, it's
>    returned in feffit.residual, or something along those lines (
>    http://cars9.uchicago.edu/xraylarch/fitting/results.html#fitting-results-sec)...
>    I haven't actually used this myself, so I can't say more.
>    3. *(Just a comment...)* I don't know if this would help but my
>    physics professor didn't let me trust the reduced chi-sq and gof
>    values I was getting until I found out how the errors were calculated. By
>    default, the errors are calculated by assuming that the noise is white in
>    R-space and that there's no signal at high-R, so the "signal" near your
>    rmax is the noise. (
>    http://cars9.uchicago.edu/xraylarch/xafs/utilities.html#_xafs.estimate_noise,
>    second to last paragraph)
>
>
> Hope this was at least somewhat helpful,
> ----------
> Hanyu (Alice) Zhang
> *Master's in Materials science | 2019*
>
> Research in utilizing XAFS to match current theory of metallic glasses to
> experimental data
>
> *Academic achievements:*
>
> *MASMC
> <https://en.wikipedia.org/wiki/Missouri_Academy_of_Science,_Mathematics_and_Computing>/NWMSU
> <https://www.nwmissouri.edu/>:* Associate of Science, 2014
> *CWRU <http://case.edu/>:* Bachelor's of Science in Engineering Physics
> <http://physics.case.edu/undergraduate-programs/undergrad-degree-programs/bsdegree-engrphys/>
> , 2018
> *Honors societies*: National Society of Collegiate Scholars | Tau Beta Pi
> <http://www.tbp.org> | Pi Mu Epsilon <http://pme-math.org/>
>
> *Other interests:*
>
> *Clubs*: Case Origami Circle | Case Rocket Team
> <http://caserocketteam.org> | CWRUbotix <http://cwrubotix.case.edu/> | Case
> Physics and Astronomy club | Math club
> *YouTube*: Chinese Operations Lead, Veritasium <http://veritasium.com> (5M
> subscribers) | Saturday Vlogs <http://bit.ly/AliceZhang>
>
>
>
> On Thu, Oct 4, 2018 at 8:04 PM Barbara Etschmann <
> barbara.etschmann at monash.edu> wrote:
>
>> Hello
>>
>> I'm trying to use larch to refine the coordination of Y in solution. I
>> need to use 2xO paths to fit the first shell and would like to restrain the
>> total coordination to be between 5.5 and 8.
>>
>> I can apply the constraint to each nO, but not the total, i.e.
>> nO1 = param(7.0, min=5, max=7, vary=True),
>> nO2 = param(1, vary=True),
>>  but
>> ntot1 = param(expr='nO1+nO2', min=5.0, max=8.5)
>> does not work.
>> How can I restrain the total coordination?
>>
>>
I think that should work.  But I can also believe it doesn't ;).   It may
require a recent version of Larch (0.39 or 0.40 and really lmfit).   I'll
try to verify that over the next couple of days.


Also, having some problems with the gofs and errors - the chi square is
>> rather small and often the errors are not reported and it is not clear why.
>>
>

Hm, not sure. Can you post an example?
Cheers,

--Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20181005/c4ac22a8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2018-10-05 at 12.55.59 AM.png
Type: image/png
Size: 122637 bytes
Desc: not available
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20181005/c4ac22a8/attachment-0001.png>


More information about the Ifeffit mailing list