aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-10-11 11:34:20 +0200
committerThomas White <taw@physics.org>2024-10-15 17:01:03 +0200
commit2e27eef7eafd2f5ba51a81cb6ce9fe2c8e6366fb (patch)
treeadca3ad6a1e0cc390c7e0f98127affc6979777a6 /src
parent246b67a863a3dbef2f1b27b4c7361433014580bd (diff)
Move powder ring enumeration routine into libcrystfel
It's now shared between cell_tool and smallcell
Diffstat (limited to 'src')
-rw-r--r--src/cell_tool.c95
1 files changed, 7 insertions, 88 deletions
diff --git a/src/cell_tool.c b/src/cell_tool.c
index dbd3544c..53044994 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -164,95 +164,12 @@ static int comparecells(UnitCell *cell, const char *comparecell,
}
-struct sortmerefl {
- signed int h;
- signed int k;
- signed int l;
- double resolution;
- int multi;
-};
-
-
-static int cmpres(const void *av, const void *bv)
-{
- const struct sortmerefl *a = av;
- const struct sortmerefl *b = bv;
- return a->resolution > b->resolution;
-}
-
-
static int all_rings(UnitCell *cell, SymOpList *sym, double mres)
{
- double ax, ay, az;
- double bx, by, bz;
- double cx, cy, cz;
- int hmax, kmax, lmax;
- signed int h, k, l;
- RefList *list;
+ struct powder_ring *rings;
int i, n;
- RefListIterator *iter;
- Reflection *ring;
- struct sortmerefl *sortus;
-
- cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
- hmax = mres * modulus(ax, ay, az);
- kmax = mres * modulus(bx, by, bz);
- lmax = mres * modulus(cx, cy, cz);
- list = reflist_new();
- for ( h=-hmax; h<=hmax; h++ ) {
- for ( k=-kmax; k<=kmax; k++ ) {
- for ( l=-lmax; l<=lmax; l++ ) {
-
- signed int ha, ka, la;
-
- if ( forbidden_reflection(cell, h, k, l) ) continue;
- if ( 2.0*resolution(cell, h, k, l) > mres ) continue;
-
- if ( sym != NULL ) {
-
- Reflection *refl;
-
- get_asymm(sym, h, k, l, &ha, &ka, &la);
- refl = find_refl(list, ha, ka, la);
- if ( refl == NULL ) {
- refl = add_refl(list, ha, ka, la);
- set_redundancy(refl, 1);
- } else {
- set_redundancy(refl, get_redundancy(refl)+1);
- }
-
- } else {
- Reflection *refl;
- refl = add_refl(list, h, k, l);
- set_redundancy(refl, 1);
- }
- }
- }
- }
-
- n = num_reflections(list);
- sortus = malloc(n*sizeof(struct sortmerefl));
-
- i = 0;
- for ( ring = first_refl(list, &iter);
- ring != NULL;
- ring = next_refl(ring, iter) )
- {
- signed int rh, rk, rl;
-
- get_indices(ring, &rh, &rk, &rl);
-
- sortus[i].h = rh;
- sortus[i].k = rk;
- sortus[i].l = rl;
- sortus[i].resolution = 2.0*resolution(cell, rh, rk, rl); /* one over d */
- sortus[i].multi = get_redundancy(ring);
- i++;
-
- }
-
- qsort(sortus, n, sizeof(struct sortmerefl), cmpres);
+ rings = powder_rings(cell, sym, mres, &n);
STATUS("\nAll powder rings up to %f Ångstrøms.\n", 1e+10/mres);
STATUS("Note that screw axis or glide plane absences are not "
@@ -261,11 +178,13 @@ static int all_rings(UnitCell *cell, SymOpList *sym, double mres)
STATUS("------------------------------------------------------\n");
for ( i=0; i<n; i++ ) {
printf("%10.3f %10.3e %4i %4i %4i m = %i\n",
- 1e10/sortus[i].resolution, sortus[i].resolution,
- sortus[i].h, sortus[i].k, sortus[i].l,
- sortus[i].multi);
+ 1e10/rings[i].resolution, rings[i].resolution,
+ rings[i].h, rings[i].k, rings[i].l,
+ rings[i].multi);
}
+ free(rings);
+
return 0;
}