-
Notifications
You must be signed in to change notification settings - Fork 1
Effective masses #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Effective masses #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,57 @@ | ||
| # This file should contain all spectroscopy specifc stuff like correlators, fits, effective masses, ... | ||
| function effectivemass(c) | ||
| N = length(c) | ||
| m = similar(c) | ||
| for i in 1:N | ||
| r = c[i]/c[mod1(i+1,N)] | ||
| m[i] = r > 0 ? abs(log(r)) : NaN | ||
| end | ||
| return m | ||
| end | ||
| function effectivemass_err(c,Δc;norm=1) | ||
| N = length(c) | ||
| Δm = similar(c) | ||
| for i in 1:N | ||
| j = mod1(i+1,N) | ||
| Δm[i] = norm(Δc[i]/c[i],Δc[j]/c[j],p=norm) | ||
| end | ||
| return Δm | ||
| end | ||
| effectivemass_err_sys(c,Δc) = effectivemass_err(c,Δc,norm=1) | ||
| effectivemass_err_stat(c,Δc) = effectivemass_err(c,Δc,norm=2) | ||
| """ | ||
| effectivemass(c) | ||
|
|
||
| Returns the effectivemass ``m_\\text{eff}(t)`` of the data ```x``` given by `` | ||
| m_\\text{eff}(t) = \\left| \\log \\left( \\frac{x(t)}{x(t+1)} \\right) \\right| ``. If | ||
| ```x``` is a vector of ```DataPoint```'s the statistical and systematic | ||
| uncertainties are propagated accordingly. If ```x <: Number``` only the the mean | ||
| value is calculated. In that case the unexported methods | ||
| ```effectivemass_err_stat(x,Δx)``` and ```effectivemass_err_sys(x,Δx)``` can be | ||
| used for propagation of uncertainty. | ||
| """ | ||
| function effectivemass(c::Vector{DataPoint{T}}) where T | ||
| # here are some allocations that are not strictly needed | ||
| val = value.(c) | ||
| stat = staterr.(c) | ||
| sys = syserr.(c) | ||
| return DataPoint.(effectivemass(val),effectivemass_err_stat(val,stat),effectivemass_err_sys(val,sys)) | ||
| end | ||
| function effectivemass_cosh(c) | ||
| T = length(c) | ||
| t = 1:T | ||
| mid = div(T,2)+1 # 1-based indexing | ||
| return @. abs(acosh(c/c[mid])/(mid-t)) | ||
| end | ||
| _acoshderiv(x) = 1/sqrt(x^2 + 1) | ||
| function effectivemass_cosh_err(c,Δc;norm=1) | ||
| T = length(c) | ||
| mid = div(T,2) + 1 # 1-based indexing | ||
| Δm = similar(c) | ||
| for t in 1:T | ||
| err1 = _acoshderiv(c[t]/c[mid])*Δc[t]/c[mid] | ||
| err2 = _acoshderiv(c[t]/c[mid])*c[t]*Δc[mid]/c[mid]^2 | ||
| Δm[t] = LinearAlgebra.norm((err1,err2),norm)/abs(mid-t) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay since you called a variable |
||
| end | ||
| return Δm | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the
abs()function here.Personally I prefer to keep the minus sign explicitely. Though I am not sure what is actually the correct way according to the community.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that there is a correct way of doing this, but all books seem to use the version without
abs(). Of course this does not matter if you only consider the range up to N_T/2 so I am fine with dropping theabs().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I also think without
abs()is a bit cleaner (and probably minimally faster 😉).Especially without this you can more easily differ between a
sinh()- orcosh()-behaviour wether the interpolators are sink or source ones.