aboutsummaryrefslogtreecommitdiff
path: root/src/molecule_posn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/molecule_posn.c')
-rw-r--r--src/molecule_posn.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/molecule_posn.c b/src/molecule_posn.c
index 603d3e1..663d917 100644
--- a/src/molecule_posn.c
+++ b/src/molecule_posn.c
@@ -137,6 +137,11 @@ static const char *rcsid = "$Header$";
@vtype fp x
@endvar
+ @var debug
+ @vdesc A debugging flag (0 = no debug output, > 0 = print debug output)
+ @vtype int x
+ @endvar
+
@var i_center
@vdesc A pointer to an value where this function should
store the integer coordinate of the molecule center,
@@ -177,8 +182,25 @@ int AEILocalInterp_molecule_posn(fp grid_origin, fp grid_delta,
fp boundary_extrapolation_tolerance_min,
fp boundary_extrapolation_tolerance_max,
fp x,
+ int debug,
int* i_center, fp* x_rel)
{
+if (debug >= 8)
+ then {
+ printf("AEILocalInterp_molecule_posn():\n");
+ printf(" grid_origin=%g grid_delta=%g\n",
+ (double) grid_origin, (double) grid_delta);
+ printf(" grid_i_[min,max]=[%d,%d] molecule_size=%d\n",
+ grid_i_min, grid_i_max, molecule_size);
+ printf(" boundary_off_centering_tolerance_[min,max]=[%g,%g]\n",
+ (double) boundary_off_centering_tolerance_min,
+ (double) boundary_off_centering_tolerance_max);
+ printf(" boundary_extrapolation_tolerance_[min,max]=[%g,%g]\n",
+ (double) boundary_extrapolation_tolerance_min,
+ (double) boundary_extrapolation_tolerance_max);
+ printf(" x=%g\n", (double) x);
+ }
+
/* molecule radia (inherently positive) in +/- directions */
const int mr_plus = (molecule_size >> 1);
const int mr_minus = molecule_size - mr_plus - 1;
@@ -194,6 +216,17 @@ const fp fp_centered_max_possible_i = grid_i_max - mr_plus + centered_max_x_rel
/* integer coordinate i of interpolation point, as a floating-point number */
const fp fp_i = (x - grid_origin) / grid_delta;
+if (debug > 8)
+ then {
+ printf(" mr_{plus,minus}={%d,%d}\n", mr_plus, mr_minus);
+ printf(" centered_[min,max]_x_rel=[%g,%g]\n",
+ (double) centered_min_x_rel, (double) centered_max_x_rel);
+ printf(" fp_centered_[min,max]_possible_i=[%g,%g]\n",
+ (double) fp_centered_min_possible_i,
+ (double) fp_centered_max_possible_i);
+ printf(" fp_i=%g\n", (double) fp_i);
+ }
+
/* is the molecule larger than the grid? */
if (molecule_size > HOW_MANY_IN_RANGE(grid_i_min,grid_i_max))
then return MOLECULE_POSN_ERROR_GRID_TINY; /*** ERROR RETURN ***/
@@ -217,6 +250,9 @@ fp fp_i_center = IS_EVEN(molecule_size) /* ... as a floating-point number */
? floor(fp_i)
: JT_ROUND(fp_i);
int int_i_center = (int) fp_i_center; /* ... as an integer */
+if (debug > 8)
+ then printf(" initial: fp_i_center=%g int_i_center=%d\n",
+ (double) fp_i_center, int_i_center);
/* then clamp the molecule at the grid boundaries */
if (int_i_center < grid_i_min) int_i_center = grid_i_min;
@@ -232,6 +268,11 @@ if (int_i_center > grid_i_max - mr_plus)
fp_i_center = (fp) int_i_center;
}
+if (debug > 8)
+ then printf(
+ " final result after clamping: fp_i_center=%g int_i_center=%d\n",
+ (double) fp_i_center, int_i_center);
+
/* store the results */
if (i_center != NULL)
then *i_center = int_i_center;