def __init__(self, xray_structure, miller_set, manager=None, cos_sin_table=False, algorithm="direct"): """Evaluate structure factors via direct calculations :type xray_structure: cctbx.xray.structure :param xray_structure: the X-ray structure to evaluate the structure factors of :type miller_set: cctbx.miller.set :param miller_set: the set of miller indices to evaluate the structure factors at :type manager: cctbx.xray.structure_factors.manager :param manager: ? (TODO: doc) :type algorithm: string :param algorithm: the name of the evaluation method, either \ "direct", "use_alt_parallel" :type cos_sin_table: boolean :param cos_sin_table: If set to 'True' a precalculated cos_sin_table is used \ instead of actual trigonometric functions. Using a manager overrides this \ setting with the one specified in the manager. :rtype: cctbx.xray.structure_factors.from_scatterers_direct :retruns: an instance `e` of `cctbx.xray.structure_factors.from_scatterers_direct` \ providing the evaluated structure factors as `e.f_calc()` """ time_all = user_plus_sys_time() managed_calculation_base.__init__(self, manager, xray_structure, miller_set, algorithm="direct") if hasattr(algorithm, "use_alt_parallel"): #enumeration of indices() is fast compared to direct summation from cctbx.xray.structure_factors.from_scatterers_direct_parallel import pprocess pprocess(self, algorithm) return timer = user_plus_sys_time() if (manager is not None): cos_sin_table = manager.cos_sin_table() if (cos_sin_table == True): cos_sin_table = default_cos_sin_table elif (cos_sin_table == False): cos_sin_table = None if (cos_sin_table is None): self._results = ext.structure_factors_direct( self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), self._xray_structure.scattering_type_registry()) else: self._results = ext.structure_factors_direct( cos_sin_table, self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), self._xray_structure.scattering_type_registry()) if (manager is not None): manager.estimate_time_direct.register( xray_structure.scatterers().size() * miller_set.indices().size(), timer.elapsed()) global_counters.from_scatterers_direct.process(time_all.elapsed())
def __init__(self, xray_structure, miller_set, manager=None, cos_sin_table=False, algorithm="direct"): """Evaluate structure factors via direct calculations :type xray_structure: cctbx.xray.structure :param xray_structure: the X-ray structure to evaluate the structure factors of :type miller_set: cctbx.miller.set :param miller_set: the set of miller indices to evaluate the structure factors at :type manager: cctbx.xray.structure_factors.manager :param manager: ? (TODO: doc) :type algorithm: string :param algorithm: the name of the evaluation method, either \ "direct", "use_alt_parallel" :type cos_sin_table: boolean :param cos_sin_table: If set to 'True' a precalculated cos_sin_table is used \ instead of actual trigonometric functions. Using a manager overrides this \ setting with the one specified in the manager. :rtype: cctbx.xray.structure_factors.from_scatterers_direct :retruns: an instance `e` of `cctbx.xray.structure_factors.from_scatterers_direct` \ providing the evaluated structure factors as `e.f_calc()` """ time_all = user_plus_sys_time() managed_calculation_base.__init__(self, manager, xray_structure, miller_set, algorithm="direct") if hasattr(algorithm,"use_alt_parallel"): #enumeration of indices() is fast compared to direct summation from cctbx.xray.structure_factors.from_scatterers_direct_parallel import pprocess pprocess(self,algorithm) return timer = user_plus_sys_time() if (manager is not None): cos_sin_table = manager.cos_sin_table() if (cos_sin_table == True): cos_sin_table = default_cos_sin_table elif (cos_sin_table == False): cos_sin_table = None if (cos_sin_table is None): self._results = ext.structure_factors_direct( self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), self._xray_structure.scattering_type_registry()) else: self._results = ext.structure_factors_direct( cos_sin_table, self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), self._xray_structure.scattering_type_registry()) if (manager is not None): manager.estimate_time_direct.register( xray_structure.scatterers().size() * miller_set.indices().size(), timer.elapsed()) global_counters.from_scatterers_direct.process(time_all.elapsed())
def __init__(self, manager, xray_structure, miller_set, algorithm="fft"): scattering_type_registry = xray_structure.scattering_type_registry() if (len(scattering_type_registry.unassigned_types()) > 0): self.show_unknown_scatterers(registry=scattering_type_registry) time_all = user_plus_sys_time() managed_calculation_base.__init__(self, manager, xray_structure, miller_set, algorithm="fft") assert miller_set.d_min() > manager.d_min() * (1 - 1e-6) manager.setup_fft() # before timing time_sampling = user_plus_sys_time() sampled_density = ext.sampled_model_density( unit_cell=xray_structure.unit_cell(), scatterers=xray_structure.scatterers(), scattering_type_registry=scattering_type_registry, fft_n_real=manager.rfft().n_real(), fft_m_real=manager.rfft().m_real(), u_base=manager.u_base(), wing_cutoff=manager.wing_cutoff(), exp_table_one_over_step_size=manager.exp_table_one_over_step_size( ), force_complex=manager.force_complex(), sampled_density_must_be_positive=manager. sampled_density_must_be_positive(), tolerance_positive_definite=manager.tolerance_positive_definite()) time_sampling = time_sampling.elapsed() time_fft = user_plus_sys_time() if (not sampled_density.anomalous_flag()): sf_map = manager.rfft().forward(sampled_density.real_map()) collect_conj = True else: sf_map = manager.cfft().backward(sampled_density.complex_map()) collect_conj = False time_fft = time_fft.elapsed() time_from_map = user_plus_sys_time() self._f_calc_data = maptbx.structure_factors.from_map( space_group=miller_set.space_group(), anomalous_flag=sampled_density.anomalous_flag(), miller_indices=miller_set.indices(), complex_map=sf_map, conjugate_flag=collect_conj).data() time_from_map = time_from_map.elapsed() time_apply_u_extra = user_plus_sys_time() sampled_density.eliminate_u_extra_and_normalize( miller_set.indices(), self._f_calc_data) time_apply_u_extra = time_apply_u_extra.elapsed() introspection.virtual_memory_info().update_max() manager.estimate_time_fft.register( n_scatterers=xray_structure.scatterers().size(), n_miller_indices=miller_set.indices().size(), time_sampling=time_sampling, time_fft=time_fft, time_from_or_to_map=time_from_map, time_apply_u_extra=time_apply_u_extra) global_counters.from_scatterers_fft.process(time_all.elapsed())
def __init__(self, manager, xray_structure, miller_set, algorithm="fft"): time_all = user_plus_sys_time() managed_calculation_base.__init__(self, manager, xray_structure, miller_set, algorithm="fft") assert miller_set.d_min() > manager.d_min() * (1-1e-6) manager.setup_fft() # before timing time_sampling = user_plus_sys_time() sampled_density = ext.sampled_model_density( unit_cell=xray_structure.unit_cell(), scatterers=xray_structure.scatterers(), scattering_type_registry=xray_structure.scattering_type_registry(), fft_n_real=manager.rfft().n_real(), fft_m_real=manager.rfft().m_real(), u_base=manager.u_base(), wing_cutoff=manager.wing_cutoff(), exp_table_one_over_step_size=manager.exp_table_one_over_step_size(), force_complex=manager.force_complex(), sampled_density_must_be_positive= manager.sampled_density_must_be_positive(), tolerance_positive_definite=manager.tolerance_positive_definite()) time_sampling = time_sampling.elapsed() time_fft = user_plus_sys_time() if (not sampled_density.anomalous_flag()): sf_map = manager.rfft().forward(sampled_density.real_map()) collect_conj = True else: sf_map = manager.cfft().backward(sampled_density.complex_map()) collect_conj = False time_fft = time_fft.elapsed() time_from_map = user_plus_sys_time() self._f_calc_data = maptbx.structure_factors.from_map( space_group=miller_set.space_group(), anomalous_flag=sampled_density.anomalous_flag(), miller_indices=miller_set.indices(), complex_map=sf_map, conjugate_flag=collect_conj).data() time_from_map = time_from_map.elapsed() time_apply_u_extra = user_plus_sys_time() sampled_density.eliminate_u_extra_and_normalize( miller_set.indices(), self._f_calc_data) time_apply_u_extra = time_apply_u_extra.elapsed() introspection.virtual_memory_info().update_max() manager.estimate_time_fft.register( n_scatterers=xray_structure.scatterers().size(), n_miller_indices=miller_set.indices().size(), time_sampling=time_sampling, time_fft=time_fft, time_from_or_to_map=time_from_map, time_apply_u_extra=time_apply_u_extra) global_counters.from_scatterers_fft.process(time_all.elapsed())