def find_candidate_orientation_matrices(self, candidate_basis_vectors): candidate_crystal_models = combinations.candidate_orientation_matrices( candidate_basis_vectors, max_combinations=self.params.basis_vector_combinations.max_combinations, ) if self._symmetry_handler.target_symmetry_reference_setting is not None: target_symmetry = self._symmetry_handler.target_symmetry_reference_setting elif self._symmetry_handler.target_symmetry_primitive is not None: target_symmetry = self._symmetry_handler.target_symmetry_primitive else: target_symmetry = None if target_symmetry is not None: candidate_crystal_models = combinations.filter_known_symmetry( candidate_crystal_models, target_symmetry, relative_length_tolerance=self.params.known_symmetry.relative_length_tolerance, absolute_angle_tolerance=self.params.known_symmetry.absolute_angle_tolerance, max_delta=self.params.known_symmetry.max_delta, ) if self.refined_experiments is not None and len(self.refined_experiments) > 0: candidate_crystal_models = combinations.filter_similar_orientations( candidate_crystal_models, self.refined_experiments.crystals(), minimum_angular_separation=self.params.multiple_lattice_search.minimum_angular_separation, ) return candidate_crystal_models
def test_combinations(setup_rlp): max_cell = 1.3 * max( setup_rlp["crystal_symmetry"].unit_cell().parameters()[:3]) strategy = FFT1D(max_cell) basis_vectors, used = strategy.find_basis_vectors(setup_rlp["rlp"]) target_symmetry_primitive = ( setup_rlp["crystal_symmetry"].primitive_setting().customized_copy( space_group_info=sgtbx.space_group().info())) target_symmetry_sg_only = ( setup_rlp["crystal_symmetry"].primitive_setting().customized_copy( unit_cell=None)) target_symmetry_ref = setup_rlp["crystal_symmetry"].as_reference_setting() for target_symmetry in ( setup_rlp["crystal_symmetry"], target_symmetry_primitive, target_symmetry_sg_only, target_symmetry_ref, ): crystal_models = combinations.candidate_orientation_matrices( basis_vectors, max_combinations=50) crystal_models = list(crystal_models) filtered_crystal_models = combinations.filter_known_symmetry( crystal_models, target_symmetry=target_symmetry) filtered_crystal_models = list(filtered_crystal_models) assert filtered_crystal_models for model in filtered_crystal_models: best_subgroup = find_matching_symmetry( model.get_unit_cell(), target_symmetry.space_group()) if target_symmetry.unit_cell() is not None: assert best_subgroup["best_subsym"].unit_cell().is_similar_to( setup_rlp["crystal_symmetry"].as_reference_setting(). best_cell().unit_cell(), relative_length_tolerance=0.1, absolute_angle_tolerance=5, ) or best_subgroup["best_subsym"].minimum_cell().unit_cell( ).is_similar_to( setup_rlp["crystal_symmetry"].as_reference_setting(). best_cell().minimum_cell().unit_cell(), relative_length_tolerance=0.1, absolute_angle_tolerance=5, ) else: target_sg = (target_symmetry.space_group_info(). reference_setting().group()) subgroups = metric_subgroups(model.get_crystal_symmetry(), max_delta=5, bravais_types_only=False) assert target_sg.build_derived_patterson_group() in [ g["ref_subsym"].space_group() for g in subgroups.result_groups ]