praxes / hexrd

Legacy hexrd repository (python2.7)
http://hexrd.readthedocs.org
14 stars 42 forks source link

Fibersearch efficiency #24

Open donald-e-boyce opened 11 years ago

donald-e-boyce commented 11 years ago

The current implementation of fibersearch is very inefficient, basically checking a large number of orientations on each fiber (as I understand it) to determine whether the orientaton would produce spots that match the experimental data within certain tolerances. I suggest improving this by using a standard minimizer (golden or brent in scipy.optimize).

The objective function should be based on the angular differences (two-theta, eta and omega) and on the required completeness. For example, for a given orientation, compute the three angular differences between predicted and experiment and find the max of the three values for all reflections under consideration. For a given completeness, c, ignore the highest (1-c) proportion of values. Take the objective function to be the maximum of the remaining values. The initial bracket for the solution would be (0, tau) (tau = 2*pi). The solution on each fiber should be found in 10-20 evaluations, instead of the usual 360 we commonly use now.

After finding the best solution on a fiber, we still apply the defined angular tolerances before accepting it as a grain.

Another issue with the current approach is that acceptance is based on the specified angular tolerances, and once an orientation is accepted as a grain, no effort is made to improve the orientation. The effect is that refining the search does not always lead to better solutions since it will return the first point on the fiber whose orientation produces acceptable tolerances (as I understand it). This also affect the strain analysis since errors in the orientation will propagate.

joelvbernier commented 11 years ago

I will generate a more detailed reply soon, but the main problem with using optimizer as you suggest is that the set of orientations that match change drastically over a given fiber. In other words, the function is very sharp and minimizing distances on a fixed subset of reflections may not be feasible, since in general it is likely that certain reflections wont be able to satisfy a Bragg condition at some point along the fiber. Off the top of my head, I can't think of an efficient way to precompute a fixed subset of reflections that would be valid over the entire length of the fiber, but that might be possible (and necessary to employ the approach you're talking about).

On the other hand, It should be possible to significantly speed up the paintgrid algorithm inside the indexer module. Frankie Implemented it inside his C++ code base, and was able on a serial process to test 5 million reflections in <5 minutes. I was thinking that we might take some of the most expensive routines, and code them up in Fortran 90 modules. Nathan and I discovered that the py2fort function inside scipy works quite well!

Sent from my iPhone

On May 9, 2013, at 6:21, Donald Boyce notifications@github.com wrote:

The current implementation of fibersearch is very inefficient, basically checking a large number of orientations on each fiber (as I understand it) to determine whether the orientaton would produce spots that match the experimental data within certain tolerances. I suggest improving this by using a standard minimizer (golden or brent in scipy.optimize).

The objective function should be based on the angular differences (two-theta, eta and omega) and on the required completeness. For example, for a given orientation, compute the three angular differences between predicted and experiment and find the max of the three values for all reflections under consideration. For a given completeness, c, ignore the highest (1-c) proportion of values. Take the objective function to be the maximum of the remaining values. The initial bracket for the solution would be (0, tau) (tau = 2*pi). The solution on each fiber should be found in 10-20 evaluations, instead of the usual 360 we commonly use now.

After finding the best solution on a fiber, we still apply the defined angular tolerances before accepting it as a grain.

Another issue with the current approach is that acceptance is based on the specified angular tolerances, and once an orientation is accepted as a grain, no effort is made to improve the orientation. The effect is that refining the search does not always lead to better solutions since it will return the first point on the fiber whose orientation produces acceptable tolerances (as I understand it). This also affect the strain analysis since errors in the orientation will propagate.

— Reply to this email directly or view it on GitHub.