Esempio n. 1
0
static int lauennn(int axes[3],
		   SPGCONST PointSymmetry * pointsym,
		   const int rot_order)
{
  int i, count, axis;
  int prop_rot[3][3];

  for (i = 0; i < 3; i++) { axes[i] = -1; }
  count = 0;
  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot, pointsym->rot[i]);

    /* Search two- or four-fold rotation */
    if ((mat_get_trace_i3(prop_rot) == -1 && rot_order == 2) ||
	(mat_get_trace_i3(prop_rot) == 1 && rot_order == 4)) {
      axis = get_rotation_axis(prop_rot);
      if (! ((axis == axes[0]) ||
	     (axis == axes[1]) ||
	     (axis == axes[2]))) {
	axes[count] = axis;
	count++;
      }
    }
  }

  sort_axes(axes);

  return 1;
}
Esempio n. 2
0
static int lauem3m(int axes[3],
		   SPGCONST PointSymmetry * pointsym)
{
  int i, count, axis, tmpval;
  int prop_rot[3][3];

  for (i = 0; i < 3; i++) { axes[i] = -1; }
  count = 0;
  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot, pointsym->rot[i]);

    /* Search four-fold rotation */
    if (! (mat_get_trace_i3(prop_rot) == 1)) {
      continue;
    }

    axis = get_rotation_axis(prop_rot);
    if (! ((axis == axes[0]) ||
	   (axis == axes[1]) ||
	   (axis == axes[2]))) {
      axes[count] = axis;
      count++;
    }
  }

  sort_axes(axes);

  return 1;
}
Esempio n. 3
0
static int lauem3m( int axes[3],
		    const Symmetry * symmetry )
{
  int i, count, axis, tmpval;
  int prop_rot[3][3], t_mat[3][3];

  for ( i = 0; i < 3; i++ ) { axes[i] = -1; }
  count = 0;
  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search four-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot ) == 1 ) ) {
      continue;
    }

    axis = get_rotation_axis( prop_rot );
    if ( ! ( ( axis == axes[0] ) ||
	     ( axis == axes[1] ) ||
	     ( axis == axes[2] ) ) ) {
      axes[count] = axis;
      count++;
    }
  }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;
}
Esempio n. 4
0
static int laue4m(int axes[3],
		  SPGCONST PointSymmetry * pointsym)
{
  int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
  int axis_vec[3];
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot, pointsym->rot[i]);

    /* Search foud-fold rotation */
    if ( mat_get_trace_i3(prop_rot) == 1) {
      /* The first axis */
      axes[2] = get_rotation_axis(prop_rot);
      break;
    }
  }

  /* The second axis */
  num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 4);
  if (! num_ortho_axis) { goto err; }
  
  min_norm = 8;
  is_found = 0;
  for (i = 0; i < num_ortho_axis; i++) {
    norm = mat_norm_squared_i3(rot_axes[ortho_axes[i]]);
    if (norm < min_norm) {
      min_norm = norm;
      axes[0] = ortho_axes[i];
      is_found = 1;
    }
  }
  if (! is_found) { goto err; }
  
  /* The third axis */
  mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]);
  is_found = 0;
  for (i = 0; i < NUM_ROT_AXES; i++) {
    if (is_exist_axis(axis_vec, i)) {
      is_found = 1;
      axes[1] = i;
      break;
    }
  }
  if (! is_found) { goto err; }

  set_transformation_matrix(t_mat, axes);
  if (mat_get_determinant_i3(t_mat) < 0) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Esempio n. 5
0
static int laue3m(int axes[3],
		  SPGCONST PointSymmetry * pointsym)
{
  int i, is_found, tmpval, axis;
  int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3];
  int axis_vec[3];

  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot, pointsym->rot[i]);

    /* Search three-fold rotation */
    if (mat_get_trace_i3(prop_rot) == 0) {
      /* The first axis */
      axes[2] = get_rotation_axis(prop_rot);
      debug_print("laue3m prop_rot\n");
      debug_print_matrix_i3(prop_rot);
      break;
    }
  }

  is_found = 0;
  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot2, pointsym->rot[i]);

    /* Search two-fold rotation */
    if (! (mat_get_trace_i3(prop_rot2) == -1)) {
      continue;
    }

    /* The second axis */
    axis = get_rotation_axis(prop_rot2);
    if (! (axis == axes[2])) {
      axes[0] = axis;
      is_found = 1;
      break;
    }
  }
  if (! is_found) { goto err; }

  /* The third axis */
  mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]);
  is_found = 0;
  for (i = 0; i < NUM_ROT_AXES; i++) {
    is_found = is_exist_axis(axis_vec, i);
    if (is_found == 1) {
      axes[1] = i;
      break;
    }
    if (is_found == -1) {
      axes[1] = i + NUM_ROT_AXES;
      break;
    }
  }
  if (! is_found) { goto err; }

  set_transformation_matrix(t_mat, axes);
  if (mat_get_determinant_i3(t_mat) < 0) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Esempio n. 6
0
static int laue_one_axis(int axes[3],
			 SPGCONST PointSymmetry * pointsym,
			 const int rot_order)
{
  int i, j, num_ortho_axis, det, is_found, tmpval;
  int axis_vec[3], tmp_axes[3];
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  debug_print("laue_one_axis with rot_order %d\n", rot_order);
  
  for (i = 0; i < pointsym->size; i++) {
    get_proper_rotation(prop_rot, pointsym->rot[i]);

    /* Search foud-fold rotation */
    if (rot_order == 4) {
      if (mat_get_trace_i3(prop_rot) == 1) {
	/* The first axis */
	axes[2] = get_rotation_axis(prop_rot);
	break;
      }
    }

    /* Search three-fold rotation */
    if (rot_order == 3) {
      if (mat_get_trace_i3(prop_rot) == 0) {
	/* The first axis */
	axes[2] = get_rotation_axis(prop_rot);
	break;
      }
    }
  }

  /* Candidates of the second axis */
  num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, rot_order);
  if (! num_ortho_axis) { goto err; }

  tmp_axes[1] = -1;
  tmp_axes[2] = axes[2];
  for (i = 0; i < num_ortho_axis; i++) {
    is_found = 0;
    tmp_axes[0] = ortho_axes[i];
    mat_multiply_matrix_vector_i3(axis_vec,
				  prop_rot,
				  rot_axes[tmp_axes[0]]);
    for (j = 0; j < num_ortho_axis; j++) {
      is_found = is_exist_axis(axis_vec, ortho_axes[j]);
      if (is_found == 1) {
	tmp_axes[1] = ortho_axes[j];
	break;
      }
      if (is_found == -1) {
	tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
	break;
      }
    }

    if (!is_found) { continue; }
    
    set_transformation_matrix(t_mat, tmp_axes);
    det = abs(mat_get_determinant_i3(t_mat));
    if (det < 4) { /* to avoid F-center choice det=4 */
      axes[0] = tmp_axes[0];
      axes[1] = tmp_axes[1];
      goto end;
    }
  }

 err: /* axes are not correctly found. */
  warning_print("spglib: Secondary axis is not found.");
  warning_print("(line %d, %s).\n", __LINE__, __FILE__);
  return 0;

 end:
  set_transformation_matrix(t_mat, axes);
  if (mat_get_determinant_i3(t_mat) < 0) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  debug_print("axes[0] = %d\n", axes[0]);
  debug_print("axes[1] = %d\n", axes[1]);
  debug_print("axes[2] = %d\n", axes[2]);

  return 1;

}
Esempio n. 7
0
static int laue_one_axis( int axes[3],
			  const Symmetry * symmetry,
			  const int rot_order )
{
  int i, j, num_ortho_axis, det, min_det, is_found, tmpval;
  int axis_vec[3], tmp_axes[3];
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search foud-fold rotation */
    if ( rot_order == 4 ) {
      if (  mat_get_trace_i3( prop_rot ) == 1 ) {
	/* The first axis */
	axes[2] = get_rotation_axis( prop_rot );
	break;
      }
    }

    /* Search three-fold rotation */
    if ( rot_order == 3 ) {
      if (  mat_get_trace_i3( prop_rot ) == 0 ) {
	/* The first axis */
	axes[2] = get_rotation_axis( prop_rot );
	break;
      }
    }
  }

  /* Candidates of the second axis */
  num_ortho_axis = get_orthogonal_axis( ortho_axes, prop_rot, rot_order );
  if ( ! num_ortho_axis ) { goto err; }

  tmp_axes[2] = axes[2];
  min_det = 4;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    tmp_axes[0] = ortho_axes[i];
    mat_multiply_matrix_vector_i3( axis_vec, prop_rot,
				   rot_axes[tmp_axes[0]] );
    for ( j = 0; j < num_ortho_axis; j++ ) {
      is_found = is_exist_axis( axis_vec, ortho_axes[j] );
      if ( is_found == 1 ) {
	tmp_axes[1] = ortho_axes[j];
	break;
      }
      if ( is_found == -1 ) {
	tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
	break;
      }
    }

    get_transform_matrix( t_mat, tmp_axes );
    det = mat_get_determinant_i3( t_mat );
    if ( det < 0 ) { det = -det; }
    if ( det < min_det ) {
      min_det = det;
      axes[0] = tmp_axes[0];
      axes[1] = tmp_axes[1];
    }
  }
  if ( ! is_found ) { goto err; }
  
  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Esempio n. 8
0
static int laue4mmm( int axes[3],
		     const Symmetry * symmetry )
{
  int i, is_found, tmpval, axis;
  int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3];
  int axis_vec[3];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search foud-fold rotation */
    if ( mat_get_trace_i3( prop_rot ) == 1 ) {
      /* The first axis */
      axes[2] = get_rotation_axis( prop_rot );
      break;
    }
  }

  is_found = 0;
  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot2, symmetry->rot[i] );

    /* Search two-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot2 ) == -1 ) ) {
      continue;
    }

    /* The second axis */
    axis = get_rotation_axis( prop_rot2 );
    if ( ! ( axis == axes[2] ) ) {
      axes[0] = axis;
      is_found = 1;
      break;
    }
  }
  if ( ! is_found ) { goto err; }


  /* The third axis */
  mat_multiply_matrix_vector_i3( axis_vec, prop_rot, rot_axes[axes[0]] );
  is_found = 0;
  for ( i = 0; i < NUM_ROT_AXES; i++ ) {
    if ( is_exist_axis( axis_vec, i ) ) {
      is_found = 1;
      axes[1] = i;
      break;
    }
  }
  if ( ! is_found ) { goto err; }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Esempio n. 9
0
static int laue2m( int axes[3],
		   const Symmetry * symmetry )
{
  int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search two-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot ) == -1 ) ) {
      continue;
    }

    /* The first axis */
    axes[1] = get_rotation_axis( prop_rot );
    break;
  }

  /* The second axis */
  num_ortho_axis = get_orthogonal_axis( ortho_axes, prop_rot, 2 );
  if ( ! num_ortho_axis ) { goto err; }
  
  min_norm = 8;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    norm = mat_norm_squared_i3( rot_axes[ortho_axes[i]] );
    if ( norm < min_norm ) {
      min_norm = norm;
      axes[0] = ortho_axes[i];
      is_found = 1;
    }
  }
  if ( ! is_found ) { goto err; }
  
  /* The third axis */
  min_norm = 8;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    norm = mat_norm_squared_i3( rot_axes[ortho_axes[i]] );
    if ( norm < min_norm && ( ! ( ortho_axes[i] == axes[0] ) ) ) {
      min_norm = norm;
      axes[2] = ortho_axes[i];
      is_found = 1;
    }
  }
  if ( ! is_found ) { goto err; }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[2];
    axes[2] = tmpval;
  }

  return 1;

 err:
  return 0;
}