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

signs of resolution matrix elements? #54

Closed
js54434 opened this issue Mar 5, 2016 · 2 comments
Closed

signs of resolution matrix elements? #54

js54434 opened this issue Mar 5, 2016 · 2 comments

Comments

@js54434
Copy link

js54434 commented Mar 5, 2016

I'm trying to generate the resolution matrix using both neutronpy and "reselps", but I'm getting some of the matrix elements to be of the opposite sign.

neutronpy code:

from neutronpy.resolution import Sample
from neutronpy.resolution import Instrument

efixed = 14.7
hcol = [50, 80, 50, 120]
vcol = [300, 300, 300, 300]
ana='PG(002)'
mono='PG(002)'

u = [1., 0., 0.]
v = [1., 0., 0.]
sample = Sample(4., 4., 4.,
                             90, 90, 90,
                             mosaic=60.,
                             u=u, v=v)
q = np.array([[2.], [0.], [0.], [4.]])
sample.vmosaic=1.
EXP = Instrument(efixed=efixed, sample=sample, hcol=hcol, vcol=vcol,
                             ana=ana, mono=mono,
                             mono_mosaic=35., ana_mosaic=35.)
EXP.calc_resolution(q)
print(EXP.RMS)

neutronpy result:

[[ 2265.98963477   299.07421529     0.           -43.68486242]
 [  299.07421529  1667.51953788     0.          -145.49237605]
 [    0.             0.            90.07679538     0.        ]
 [  -43.68486242  -145.49237605     0.            14.42250498]]

With similar parameters,

epm = 1
ep = 1
alz, alm, ala, al3 = 50, 80, 50, 120
tm, ta = 1.87325, 1.87325
etam, etaa = 35., 35.
efix = -14.7
etash = 60.
etasv = 1.
source = 1
vbetz, vbet1, vbet2, vbet3 = 300, 300, 300, 300

the reselps code has this result:

[[ 2265.99375019  -299.07567774   -43.6850311      0.        ]
 [ -299.07567774  1667.52554288   145.49293785     0.        ]
 [  -43.6850311    145.49293785    14.42256067     0.        ]
 [    0.             0.             0.            90.07572559]]

(the z and energy indices are swapped). It looks like the y-row and y-column are multiplied by -1. Can you think of a reason for this discrepancy? Is the "y" direction defined as clockwise relative to Q rather than counterclockwise as in the reselps code?

@pseudocubic
Copy link
Contributor

After looking into it, the scattering is calculated for a left-handed coordinate frame (y is defined being clockwise from x). There is an implementation for changing to a right-handed one, but I haven't pushed it due to incomplete testing. In principle, the mondir attribute should control this but it hasn't been setup completely. I will look into this a little more now.

@pseudocubic
Copy link
Contributor

Ok, so I was correct in saying that the default is to use a left-handed coordinate frame, but the way to change it is not through the mondir variable. In fact, dir1 and dir2 are also depreciated in favor of mono.dir, sample.dir, and ana.dir. These are already all implemented in the current release, so to use a right handed coordinate frame:

from neutronpy.resolution import Sample
from neutronpy.resolution import Instrument

efixed = 14.7
hcol = [50, 80, 50, 120]
vcol = [300, 300, 300, 300]
ana='PG(002)'
mono='PG(002)'

u = [1., 0., 0.]
v = [0., 1., 0.]
sample = Sample(4., 4., 4.,
                             90, 90, 90,
                             mosaic=60.,
                             u=u, v=v)
q = np.array([[2.], [0.], [0.], [4.]])
sample.vmosaic=1.
EXP = Instrument(efixed=efixed, sample=sample, hcol=hcol, vcol=vcol,
                             ana=ana, mono=mono,
                             mono_mosaic=35., ana_mosaic=35.)
EXP.mono.dir = 1
EXP.sample.dir = -1
EXP.and.dir = 1
EXP.calc_resolution(q)
print(EXP.RMS)

The above code should output

[[ 2265.98963477  -299.07421529     0.           -43.68486242]
 [ -299.07421529  1667.51953788     0.           145.49237605]
 [    0.             0.            90.07679538     0.        ]
 [  -43.68486242   145.49237605     0.            14.42250498]]

I will update the documentation to reflect the correct usage.

pseudocubic pushed a commit that referenced this issue Mar 5, 2016
Resolves #54

The Instrument class attributes dir1, dir2 and mondir are depreciated in favor of mono.dir, sample.dir, and ana.dir.

These attributes control the handedness of the coordinate frame.

Documentation in _Monochromator and Instrument class is updated to reflect correct usage.
pseudocubic pushed a commit that referenced this issue Mar 8, 2016
Resolves #54

The Instrument class attributes dir1, dir2 and mondir are depreciated in favor of mono.dir, sample.dir, and ana.dir.

These attributes control the handedness of the coordinate frame.

Documentation in _Monochromator and Instrument class is updated to reflect correct usage.
pseudocubic pushed a commit that referenced this issue Mar 8, 2016
Resolves #54

The Instrument class attributes dir1, dir2 and mondir are depreciated in favor of mono.dir, sample.dir, and ana.dir.

These attributes control the handedness of the coordinate frame.

Documentation in _Monochromator and Instrument class is updated to reflect correct usage.
pseudocubic pushed a commit that referenced this issue Mar 22, 2016
Resolves #54

The Instrument class attributes dir1, dir2 and mondir are depreciated in favor of mono.dir, sample.dir, and ana.dir.

These attributes control the handedness of the coordinate frame.

Documentation in _Monochromator and Instrument class is updated to reflect correct usage.
pseudocubic pushed a commit that referenced this issue Mar 22, 2016
Resolves #54

The Instrument class attributes dir1, dir2 and mondir are depreciated in favor of mono.dir, sample.dir, and ana.dir.

These attributes control the handedness of the coordinate frame.

Documentation in _Monochromator and Instrument class is updated to reflect correct usage.
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

2 participants