Ticket #10019 (closed: fixed)
ExtendedUnit Cell Defects
Reported by: | Owen Arnold | Owned by: | Owen Arnold |
---|---|---|---|
Priority: | critical | Milestone: | Release 3.3 |
Component: | Diffraction | Keywords: | |
Cc: | saviciat@… | Blocked By: | |
Blocking: | Tester: | Andrei Savici |
Description
Apply fixes below.
First of all, the results in the test are wrong: [1,0,0] and [0,0,1] are in the horizontal plane (in Mantid convention z direction and x direction). Then the perpendicular to the plane in the up direction is [0,-1,0]. So [1,1,1] is below the plane, and the angle is arcos(-1./sqrt(3.)), not arcos(1./sqrt(3.)). Minor detail: use numpy.degrees(angle) to get the angle in degrees Here are the steps that I would use to get this algorithm: 1. Use OrientedLattice instead of Unit Cell 2. Set the U matrix using the two reflections in the plane using ol.setUFromVectors. That function takes any combination of V3Ds, lists, numpy arrays 3. Get the UB matrix and calculate Q: ol.getUB().dot(array(desiredReflection)) 4. Calculate the angles a_i=degrees(arccos(Q_i/|Q|)), with i=x,y,z. Note that the z is along beam, x perpendicular to the beam in horizontal plane, and y is vertically up. The sign thing does not make sense in 3D. a_i will have values from 0 to 180 degrees
Change History
comment:3 Changed 6 years ago by Owen Arnold
Following a helpful discussion with Andrei, we have come to the following decisions.
- ExtendedUnitCell is redundant and is providing incorrect results anyway. It also isn't using the full UBMatrix. Remove all code and tests for this.
- Pseudo code below does what we want
- The direction cosine calculation below should live on V3D as in V3D::directionAngles(), make it possible to obtain results in degrees or radians
- Expose methods above to python
V3D directionAngles(const V3D & hkl) { Q = qFromHKL(hkl); a_1 = a_i=degrees(arccos(Q[0]/Q.norm())) a_2 = a_i=degrees(arccos(Q[1]/Q.norm())) a_3 = a_i=degrees(arccos(Q[2]/Q.norm())) return V3D(a_1, a_2, a_3); }
comment:4 Changed 6 years ago by Owen Arnold
- Status changed from assigned to inprogress
refs #10019. Extend V3D and test
Changeset: 6b9bdba84d1835d08d39a126b71d404046180fa4
comment:5 Changed 6 years ago by Owen Arnold
refs #10019. Expose methods to python and test
Changeset: 5349aa950bde5d7757c69190ae9eeb4b587b9a73
comment:6 Changed 6 years ago by Owen Arnold
refs #10019. Remove ExtendedUnitCell class
Changeset: bc19bbdfe5ca637555a284b4c5da2b8eabf05f62
comment:7 Changed 6 years ago by Owen Arnold
I suggest that Andrei tests this
Tester: I have provided unit tests throughout for the new functionality. The following would also help.
import math from mantid.geometry import OrientedLattice from mantid.kernel import V3D ol = OrientedLattice(1,1,1,90,90,90) v1 = V3D(1,0,0) v2 = V3D(0,0,1) ol.setUFromVectors(v2, v1) q = ol.qFromHKL(V3D(3,1,1)) angles = q.directionAngles(False) print "angles: ", angles print "expected angles: ", [math.acos(math.sqrt(9)/math.sqrt(11)),math.acos(math.sqrt(1)/math.sqrt(11)), math.acos(math.sqrt(1)/math.sqrt(11))]
comment:8 Changed 6 years ago by Owen Arnold
- Status changed from inprogress to verify
- Resolution set to fixed
comment:9 Changed 6 years ago by Andrei Savici
- Status changed from verify to verifying
- Tester set to Andrei Savici
comment:10 Changed 6 years ago by Owen Arnold
refs #10019. Minor modifications.
Changeset: 5ea0c2f2f03e24bb18e33ac6cd05f2b495d15ea0
comment:11 Changed 6 years ago by Andrei Savici
- Status changed from verifying to reopened
- Resolution fixed deleted
For the python exports for qFromHKL and hklFromQ, one should be able to use lists or numpy arrays, similar to the case of setUFromVectors (see lines 32 to 35 in mantid/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/OrientedLattice.cpp)
comment:12 Changed 6 years ago by Owen Arnold
- Status changed from reopened to inprogress
refs #10019. More helpful about python arguments.
Following Andrei's suggestion. Internally convert to V3D from other types. I've also enabled the default choice of inDegrees for the V3D::directionAngles from the python side. All changes are unit tested.
Changeset: de3e56ae084c3c48ac75dd950b4f2e5803e4330b
comment:13 Changed 6 years ago by Owen Arnold
- Status changed from inprogress to verify
- Resolution set to fixed
comment:15 Changed 6 years ago by Andrei Savici
- Status changed from verifying to closed
Merge remote-tracking branch 'origin/feature/10019_direction_angles'
Full changeset: 9d8db81005929e3eb59f2f725983a7d76931336a
comment:16 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 10861