-
Notifications
You must be signed in to change notification settings - Fork 30
verify accuracy of fractal S(q) for small q #722
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
Open
pkienzle
wants to merge
1
commit into
master
Choose a base branch
from
check-fractal-precision
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,22 @@ | ||
| static double | ||
| fractal_sq(double q, double radius, double fractal_dim, double cor_length) | ||
| { | ||
| //calculate S(q), using Teixeira, Eq(15) | ||
| // mathematica query to check limiting conditions: | ||
| // lim x->0 of [ x gamma(x-1) sin(arctan(q c (x-1))) (q r)^(-x) (1 + 1/(q c)^2)^((1-x)/2) ] | ||
| // Note: gamma(x) may be unreliable for x<0, so the gamma(D-1) is risky. | ||
| // We instead transform D*gamma(D-1) into gamma(D+1)/(D-1). | ||
| // Calculate S(q) using Eq(16) from Teixeira (1988), DOI:10.1107/S0021889888000263 | ||
| // with terms rearranged so that limiting cases are easier to calculate. | ||
| // Values checked against 500 bit floating point using the original equations. | ||
| double term; | ||
| if (q == 0.) { | ||
| const double D = fractal_dim; | ||
| term = pow(cor_length/radius, D)*sas_gamma(D+1.); | ||
| term = pow(cor_length/radius, fractal_dim)*sas_gamma(fractal_dim+1.); | ||
| } else if (fractal_dim == 0.) { | ||
| term = 1.0; | ||
| term = 1.; | ||
| } else if (fractal_dim == 1.) { | ||
| term = atan(q*cor_length)/(q*radius); | ||
| } else { | ||
| // q>0, D>0 | ||
| const double D = fractal_dim; | ||
| const double Dm1 = fractal_dim - 1.0; | ||
| // Note: for large Dm1, sin(Dm1*atan(q*cor_length) can go negative | ||
| const double t1 = sas_gamma(D+1.)/Dm1*sin(Dm1*atan(q*cor_length)); | ||
| const double t2 = pow(q*radius, -D); | ||
| const double t3 = pow(1.0 + 1.0/square(q*cor_length), -0.5*Dm1); | ||
| const double t1 = pow(cor_length/radius, fractal_dim) * sas_gamma(fractal_dim+1.); | ||
| const double t2 = sin((fractal_dim-1.)*atan(q*cor_length))/((fractal_dim-1)*q*cor_length); | ||
| const double t3 = pow(1. + square(q*cor_length), -0.5*(fractal_dim-1.)); | ||
| term = t1 * t2 * t3; | ||
| } | ||
| return 1.0 + term; | ||
| return 1. + term; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Regarding the transformation, I multiplied$t_2$ by $(qξ)^{D-1}$ giving intermediate $t_2'' = (ξ/r)^D/(qξ)$ , and $t_3$ by $1/(qξ)^{D-1}$ giving the new $t_3'$ .
I then rearranged$t_1$ and $t_2''$ forming the new $t_2'$ using $\sin((D-1)\tan^{-1}(qξ))/(D-1)$ from $t_1$ and $1/(qξ)$ from $t_2''$ , and forming the new $t_1'$ using $Γ(D+1)$ from $t_1$ and $(ξ/r)^D$ from $t_2''$ .
Limit as$q \rightarrow 0$ for $t_2'$ and $t_3'$ are both 1, so only the constant $t_1'$ remains.
Limit as$D \rightarrow 0$ for $t_1'$ is 1. For $t_2'$ it is $\sin (\tan^{-1}(qξ))/(qξ) = 1/\sqrt{1+(qξ)^2}$ and for $t_3'$ it is $\sqrt{1 + (qξ)^2}$ which cancel.
Limit as$D \rightarrow 1$ for $t_1'$ is $ξ/r$ , for $t_2'$ is $\tan^{-1}(qξ) / (qξ)$ and for $t_3'$ is 1.
Further check: Limit$q \rightarrow 0$ for $D \rightarrow 1$ equals $ξ/r$ matches limit $D \rightarrow 1$ for $q \rightarrow 0$ .