Skip to content
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

Change the way d-spacing is calculated... #255

Open
kif opened this issue Feb 3, 2016 · 3 comments
Open

Change the way d-spacing is calculated... #255

kif opened this issue Feb 3, 2016 · 3 comments

Comments

@kif
Copy link
Member

kif commented Feb 3, 2016

Suggested by Carsten Detlefs:
You have already implemented the calculation of the d-spacings etc using
a "magic formula". The more conventional way would be to calculate the
"B matrix" from the lattice parameters, as defined e.g. by Busing and
Levy,
Acta Cryst vol 22, pp 457 (1967).

http://scripts.iucr.org/cgi-bin/paper?a05492

The Q-vector is then B*(H,K,L), and d_spacing = 2 pi/ |Q|

(but in general Q is much more useful than d).

This might be a bit faster (if that matters) as the B matrix is
calculated
only once, and after that there are no more sin/cos functions needed,
only
squares and one square root per (HKL).

@jonwright
Copy link
Collaborator

  • if you leave the 2*pi out when computing the B matrix you don't need
    to correct for it again.
  • you can also compute the reciprocal metric tensor (g=B'.B) to compute
    h'.g.h which is 1/d**2, assuming you've already removed the 2pi.

The motivation for the metric tensor is that you don't need to pick a
convention for orthogonal axes compared to crystallographic axes, you
get the scalar out directly.

See
http://sourceforge.net/p/fable/code/HEAD/tree/ImageD11/trunk/ImageD11/unitcell.py

On 03/02/2016 10:00, Jerome Kieffer wrote:

Suggested by Carsten Detlefs:
You have already implemented the calculation of the d-spacings etc using
a "magic formula" The more conventional way would be to calculate the
"B matrix" from the lattice parameters, as defined eg by Busing and
Levy,
Acta Cryst vol 22, pp 457 (1967)

http://scriptsiucrorg/cgi-bin/paper?a05492

The Q-vector is then B*(H,K,L), and d_spacing = 2 pi/ |Q|

(but in general Q is much more useful than d)

This might be a bit faster (if that matters) as the B matrix is
calculated
only once, and after that there are no more sin/cos functions needed,
only
squares and one square root per (HKL)


Reply to this email directly or view it on GitHub
https://github.com/kif/pyFAI/issues/255.

@jonwright
Copy link
Collaborator

... and now I got as far as looking at the code. You are already using
something like a reciprocal metric tensor as "Sij". These are also
called reciprocal cell quadratic products (e.g. in GSAS). Usually the
factors of 2 and volume**2 are included in the constants (labelled A-F
or RMij).

On 03/02/2016 10:00, Jerome Kieffer wrote:

Suggested by Carsten Detlefs:
You have already implemented the calculation of the d-spacings etc using
a "magic formula" The more conventional way would be to calculate the
"B matrix" from the lattice parameters, as defined eg by Busing and
Levy,
Acta Cryst vol 22, pp 457 (1967)

http://scriptsiucrorg/cgi-bin/paper?a05492

The Q-vector is then B*(H,K,L), and d_spacing = 2 pi/ |Q|

(but in general Q is much more useful than d)

This might be a bit faster (if that matters) as the B matrix is
calculated
only once, and after that there are no more sin/cos functions needed,
only
squares and one square root per (HKL)


Reply to this email directly or view it on GitHub
https://github.com/kif/pyFAI/issues/255.

@kif
Copy link
Member Author

kif commented Feb 4, 2016

On Wed, 03 Feb 2016 08:55:13 -0800
Jon Wright [email protected] wrote:

... and now I got as far as looking at the code. You are already using
something like a reciprocal metric tensor as "Sij". These are also
called reciprocal cell quadratic products (e.g. in GSAS). Usually the
factors of 2 and volume**2 are included in the constants (labelled A-F
or RMij).

Thanks for the review, Jon.

We could gain some speed in doing all matrix-vector products in one
shoot following Carsten's suggestion:
Instead of generating all hkl in Python, use Numpy and its dot-product.

This would probably make this faster but is 5 seconds to generate a
calibrant file too slow ?

I suggest to leave the issue open, as exercise for a trainee to
learn test-creation & profiling.

Cheers,

Jerome.

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

No branches or pull requests

3 participants