Skip to content

verify accuracy of fractal S(q) for small q#722

Open
pkienzle wants to merge 1 commit into
masterfrom
check-fractal-precision
Open

verify accuracy of fractal S(q) for small q#722
pkienzle wants to merge 1 commit into
masterfrom
check-fractal-precision

Conversation

@pkienzle

@pkienzle pkienzle commented May 1, 2026

Copy link
Copy Markdown
Contributor

The equations for the fractal S(q) model were complex enough that it was not immediately obvious how they would behave at small q.

This PR rearranges the equations to make the limiting cases much more apparent, and checks them against the original equations from Teixeira (1988) using 500 bit precision.

The numpy version of the equations was added to sasmodels.special so it will be available for pure python models.

@krzywon krzywon requested a review from yunliu01 June 16, 2026 13:51
@butlerpd

Copy link
Copy Markdown
Member

The only change to GUI users here is the addition of the DOI for the reference to documentation which Should be accepted. The other changes are to lib files which as far as I know are not currently available through the GUI though in principle are available through scripting? Probably we just need a code review here?

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.));

@pkienzle pkienzle Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

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$.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants