aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-04-05 21:24:34 -0700
committerThomas White <taw@physics.org>2015-04-20 15:50:40 +0200
commitb566a61d7822c66034563f34920d6e9d3b8a36de (patch)
tree4b2bce9e5806fbf0e3f01c717bba5cfb055465b2 /src
parent5280efd92f6631bd7f700b370a86c2df61291afc (diff)
Fix gradients
Diffstat (limited to 'src')
-rw-r--r--src/predict-refine.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/predict-refine.c b/src/predict-refine.c
index 99c24b40..3b8e9b68 100644
--- a/src/predict-refine.c
+++ b/src/predict-refine.c
@@ -279,6 +279,8 @@ static double x_gradient(int param, struct reflpeak *rp, struct detector *det,
double xpk, ypk, xh, yh;
double fsh, ssh;
double tt, clen, azi, azf;
+ double x, z, wn;
+ double ax, ay, az, bx, by, bz, cx, cy, cz;
twod_mapping(rp->peak->fs, rp->peak->ss, &xpk, &ypk, rp->panel);
get_detector_pos(rp->refl, &fsh, &ssh);
@@ -289,17 +291,22 @@ static double x_gradient(int param, struct reflpeak *rp, struct detector *det,
clen = rp->panel->clen;
azi = atan2(yh, xh);
azf = cos(azi);
+ wn = 1.0 / lambda;
+
+ cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
+ x = h*ax + k*bx + l*cx;
+ z = h*az + k*bz + l*cz;
switch ( param ) {
case GPARAM_ASX :
- return h * lambda * clen / cos(tt);
+ return h * clen / (wn+z);
case GPARAM_BSX :
- return k * lambda * clen / cos(tt);
+ return k * clen / (wn+z);
case GPARAM_CSX :
- return l * lambda * clen / cos(tt);
+ return l * clen / (wn+z);
case GPARAM_ASY :
return 0.0;
@@ -311,13 +318,13 @@ static double x_gradient(int param, struct reflpeak *rp, struct detector *det,
return 0.0;
case GPARAM_ASZ :
- return -h * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -h * x * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_BSZ :
- return -k * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -k * x * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_CSZ :
- return -l * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -l * x * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_DETX :
return -1;
@@ -343,6 +350,8 @@ static double y_gradient(int param, struct reflpeak *rp, struct detector *det,
double xpk, ypk, xh, yh;
double fsh, ssh;
double tt, clen, azi, azf;
+ double y, z, wn;
+ double ax, ay, az, bx, by, bz, cx, cy, cz;
twod_mapping(rp->peak->fs, rp->peak->ss, &xpk, &ypk, rp->panel);
get_detector_pos(rp->refl, &fsh, &ssh);
@@ -353,6 +362,11 @@ static double y_gradient(int param, struct reflpeak *rp, struct detector *det,
clen = rp->panel->clen;
azi = atan2(yh, xh);
azf = sin(azi);
+ wn = 1.0 / lambda;
+
+ cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
+ y = h*ay + k*by + l*cy;
+ z = h*az + k*bz + l*cz;
switch ( param ) {
@@ -366,22 +380,22 @@ static double y_gradient(int param, struct reflpeak *rp, struct detector *det,
return 0.0;
case GPARAM_ASY :
- return h * lambda * clen / cos(tt);
+ return h * clen / (wn+z);
case GPARAM_BSY :
- return k * lambda * clen / cos(tt);
+ return k * clen / (wn+z);
case GPARAM_CSY :
- return l * lambda * clen / cos(tt);
+ return l * clen / (wn+z);
case GPARAM_ASZ :
- return -h * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -h * y * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_BSZ :
- return -k * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -k * y * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_CSZ :
- return -l * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+ return -l * y * clen / (wn*wn + 2*wn*z + z*z);
case GPARAM_DETX :
return 0;