aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-02-21 16:15:06 +0100
committerThomas White <taw@physics.org>2019-03-11 16:49:37 +0100
commit3a098d01569348a9680fca45ba4786f3a15761a3 (patch)
treea19f16e08fbd1671833e3568b21e498ecdf743f6
parentd2f89b05a5c6d002135c6b5898ca5540cfcec7ea (diff)
cell_tool: Add --transform
-rw-r--r--src/cell_tool.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cell_tool.c b/src/cell_tool.c
index 6d0c5f1e..9b7d6a6b 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -329,6 +329,30 @@ static int uncenter(UnitCell *cell, const char *out_file)
}
+static int transform(UnitCell *cell, const char *trans_str)
+{
+ RationalMatrix *trans;
+ UnitCell *nc;
+
+ trans = parse_cell_transformation(trans_str);
+ if ( trans == NULL ) {
+ ERROR("Invalid cell transformation '%s'\n", trans_str);
+ return 1;
+ }
+
+ nc = cell_transform_rational(cell, trans);
+
+ STATUS("------------------> The transformation matrix:\n");
+ rtnl_mtx_print(trans);
+ STATUS("Determinant = %s\n", rtnl_format(rtnl_mtx_det(trans)));
+
+ STATUS("------------------> The transformed unit cell:\n");
+ cell_print(nc);
+
+ return 0;
+}
+
+
enum {
CT_NOTHING,
CT_FINDAMBI,
@@ -336,6 +360,7 @@ enum {
CT_RINGS,
CT_COMPARE,
CT_CHOICES,
+ CT_TRANSFORM,
};
@@ -354,6 +379,7 @@ int main(int argc, char *argv[])
char *out_file = NULL;
float highres;
double rmax = 1/(2.0e-10);
+ char *trans_str = NULL;
/* Long options */
const struct option longopts[] = {
@@ -368,6 +394,8 @@ int main(int argc, char *argv[])
{"uncentre", 0, &mode, CT_UNCENTER},
{"rings", 0, &mode, CT_RINGS},
{"compare-cell", 1, NULL, 3},
+ {"cell-choices", 0, &mode, CT_CHOICES},
+ {"transform", 1, NULL, 4},
{"highres", 1, NULL, 5},
{0, 0, NULL, 0}
@@ -404,6 +432,11 @@ int main(int argc, char *argv[])
mode = CT_COMPARE;
break;
+ case 4 :
+ trans_str = strdup(optarg);
+ mode = CT_TRANSFORM;
+ break;
+
case 5 :
if ( sscanf(optarg, "%e", &highres) != 1 ) {
ERROR("Invalid value for --highres\n");
@@ -491,6 +524,7 @@ int main(int argc, char *argv[])
if ( mode == CT_UNCENTER ) return uncenter(cell, out_file);
if ( mode == CT_RINGS ) return all_rings(cell, sym, rmax);
if ( mode == CT_COMPARE ) return comparecells(cell, comparecell, ltl, atl);
+ if ( mode == CT_TRANSFORM ) return transform(cell, trans_str);
/* FIXME: Everything else */
ERROR("Sorry, this mode of operation is not yet implemented.\n");