Ejemplo n.º 1
0
def construct_nice_cb_op(coset,
                         sym_transform_1_to_2,
                         to_niggli_1,
                         to_niggli_2):
  best_choice = None
  best_choice_as_hkl = None
  to_niggli_2 = to_niggli_2.new_denominators( to_niggli_1 )
  sym_transform_1_to_2 = sym_transform_1_to_2.new_denominators( to_niggli_1 )

  for coset_element in coset:
    tmp_coset_element = sgtbx.change_of_basis_op(coset_element)
    tmp_coset_element = tmp_coset_element.new_denominators( to_niggli_1 )
    tmp_op = to_niggli_1.inverse() \
           * (tmp_coset_element * sym_transform_1_to_2) \
           * to_niggli_2
    if (best_choice_as_hkl is None
        or sgtbx.compare_cb_op_as_hkl(
             best_choice_as_hkl, tmp_op.as_hkl()) > 0):
      best_choice = tmp_op
      best_choice_as_hkl =  tmp_op.as_hkl()
  assert best_choice is not None

  tmptmp = sgtbx.change_of_basis_op(coset[0])

  return best_choice
Ejemplo n.º 2
0
    def combined_cb_op(self, other, cb_op):
        sc = self.change_of_basis_op_to_minimum_cell
        oc = other.change_of_basis_op_to_minimum_cell

        cb_op = cb_op.new_denominators(sc)
        best_choice = None
        best_choice_as_hkl = None
        for s_symop in self.minimum_cell_symmetry.space_group():
            s_symop = sgtbx.change_of_basis_op(sgtbx.rt_mx(
                s_symop.r())).new_denominators(sc)
            for o_symop in other.minimum_cell_symmetry.space_group():
                o_symop = sgtbx.change_of_basis_op(sgtbx.rt_mx(
                    o_symop.r())).new_denominators(sc)
                possible_choice = sc.inverse() * s_symop * cb_op * o_symop * oc
                possible_choice_as_hkl = possible_choice.as_hkl()
                if (best_choice_as_hkl is None or sgtbx.compare_cb_op_as_hkl(
                        best_choice_as_hkl, possible_choice_as_hkl) > 0):
                    best_choice = possible_choice
                    best_choice_as_hkl = possible_choice_as_hkl
        assert best_choice is not None
        return best_choice
Ejemplo n.º 3
0
    def combined_cb_op(self, other, cb_op):
        sc = self.change_of_basis_op_to_minimum_cell
        oc = other.change_of_basis_op_to_minimum_cell

        cb_op = cb_op.new_denominators(sc)
        best_choice = None
        best_choice_as_hkl = None
        for s_symop in self.minimum_cell_symmetry.space_group():
            s_symop = sgtbx.change_of_basis_op(sgtbx.rt_mx(s_symop.r())).new_denominators(sc)
            for o_symop in other.minimum_cell_symmetry.space_group():
                o_symop = sgtbx.change_of_basis_op(sgtbx.rt_mx(o_symop.r())).new_denominators(sc)
                possible_choice = sc.inverse() * s_symop * cb_op * o_symop * oc
                possible_choice_as_hkl = possible_choice.as_hkl()
                if (
                    best_choice_as_hkl is None
                    or sgtbx.compare_cb_op_as_hkl(best_choice_as_hkl, possible_choice_as_hkl) > 0
                ):
                    best_choice = possible_choice
                    best_choice_as_hkl = possible_choice_as_hkl
        assert best_choice is not None
        return best_choice
Ejemplo n.º 4
0
def construct_nice_cb_op(coset, sym_transform_1_to_2, to_niggli_1,
                         to_niggli_2):
    best_choice = None
    best_choice_as_hkl = None
    to_niggli_2 = to_niggli_2.new_denominators(to_niggli_1)
    sym_transform_1_to_2 = sym_transform_1_to_2.new_denominators(to_niggli_1)

    for coset_element in coset:
        tmp_coset_element = sgtbx.change_of_basis_op(coset_element)
        tmp_coset_element = tmp_coset_element.new_denominators(to_niggli_1)
        tmp_op = to_niggli_1.inverse() \
               * (tmp_coset_element * sym_transform_1_to_2) \
               * to_niggli_2
        if (best_choice_as_hkl is None or sgtbx.compare_cb_op_as_hkl(
                best_choice_as_hkl, tmp_op.as_hkl()) > 0):
            best_choice = tmp_op
            best_choice_as_hkl = tmp_op.as_hkl()
    assert best_choice is not None

    tmptmp = sgtbx.change_of_basis_op(coset[0])

    return best_choice
Ejemplo n.º 5
0
 def best_partition_representatives(self,
                                    cb_op=None,
                                    omit_first_partition=False,
                                    omit_negative_determinants=False):
     result = []
     for partition in self.partitions:
         best_choice, best_choice_as_hkl = None, None
         for choice in partition:
             if (omit_first_partition and choice.is_unit_mx()):
                 assert best_choice is None
                 break
             if (omit_negative_determinants
                     and choice.r().determinant() < 0):
                 continue
             if (cb_op is not None):
                 choice = cb_op.apply(choice)
             choice_as_hkl = choice.r().as_hkl()
             if (best_choice_as_hkl is None or sgtbx.compare_cb_op_as_hkl(
                     best_choice_as_hkl, choice_as_hkl) > 0):
                 best_choice, best_choice_as_hkl = choice, choice_as_hkl
         if (best_choice is not None):
             result.append(best_choice)
     return result
Ejemplo n.º 6
0
 def best_partition_representatives(self,
       cb_op=None,
       omit_first_partition=False,
       omit_negative_determinants=False):
   result = []
   for partition in self.partitions:
     best_choice, best_choice_as_hkl = None, None
     for choice in partition:
       if (omit_first_partition and choice.is_unit_mx()):
         assert best_choice is None
         break
       if (omit_negative_determinants and choice.r().determinant() < 0):
         continue
       if (cb_op is not None):
         choice = cb_op.apply(choice)
       choice_as_hkl = choice.r().as_hkl()
       if (best_choice_as_hkl is None
           or sgtbx.compare_cb_op_as_hkl(
                best_choice_as_hkl, choice_as_hkl) > 0):
         best_choice, best_choice_as_hkl = choice, choice_as_hkl
     if (best_choice is not None):
       result.append(best_choice)
   return result