def __init__(self, manager, xray_structure, u_iso_refinable_params, miller_set, d_target_d_f_calc, n_parameters): time_all = time_apply_u_extra = user_plus_sys_time() gradients_base.__init__(self, manager, xray_structure, miller_set, algorithm="fft") self._d_target_d_f_calc = d_target_d_f_calc manager.setup_fft() # before timing time_apply_u_extra = user_plus_sys_time() self._results = ext.fast_gradients( unit_cell=xray_structure.unit_cell(), scatterers=xray_structure.scatterers(), scattering_type_registry=xray_structure.scattering_type_registry(), u_base=manager.u_base(), wing_cutoff=manager.wing_cutoff(), exp_table_one_over_step_size=manager.exp_table_one_over_step_size(), tolerance_positive_definite=manager.tolerance_positive_definite()) coeff = self._gradient_map_coeff() time_apply_u_extra = time_apply_u_extra.elapsed() time_from_or_to_map = user_plus_sys_time() coeff_map = self._gradient_map_coeff_to_map(coeff) time_from_or_to_map = time_from_or_to_map.elapsed() time_fft = user_plus_sys_time() if (not coeff.anomalous_flag()): gradient_map = manager.rfft().backward(coeff_map.complex_map()) else: gradient_map = manager.cfft().backward(coeff_map.complex_map()) time_fft = time_fft.elapsed() time_sampling = user_plus_sys_time() self._results.sampling( scatterers=xray_structure.scatterers(), u_iso_refinable_params=u_iso_refinable_params, scattering_type_registry=xray_structure.scattering_type_registry(), site_symmetry_table=xray_structure.site_symmetry_table(), ft_d_target_d_f_calc=gradient_map, n_parameters=n_parameters, sampled_density_must_be_positive= manager.sampled_density_must_be_positive()) time_sampling = time_sampling.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_or_to_map, time_apply_u_extra=time_apply_u_extra) self.d_target_d_site_frac_was_used = False self.d_target_d_u_star_was_used = False global_counters.gradients_fft.process(time_all.elapsed())
def __init__(self, manager, xray_structure, u_iso_refinable_params, miller_set, d_target_d_f_calc, n_parameters): time_all = time_apply_u_extra = user_plus_sys_time() gradients_base.__init__(self, manager, xray_structure, miller_set, algorithm="fft") self._d_target_d_f_calc = d_target_d_f_calc manager.setup_fft() # before timing time_apply_u_extra = user_plus_sys_time() self._results = ext.fast_gradients( unit_cell=xray_structure.unit_cell(), scatterers=xray_structure.scatterers(), scattering_type_registry=xray_structure.scattering_type_registry(), u_base=manager.u_base(), wing_cutoff=manager.wing_cutoff(), exp_table_one_over_step_size=manager.exp_table_one_over_step_size( ), tolerance_positive_definite=manager.tolerance_positive_definite()) coeff = self._gradient_map_coeff() time_apply_u_extra = time_apply_u_extra.elapsed() time_from_or_to_map = user_plus_sys_time() coeff_map = self._gradient_map_coeff_to_map(coeff) time_from_or_to_map = time_from_or_to_map.elapsed() time_fft = user_plus_sys_time() if (not coeff.anomalous_flag()): gradient_map = manager.rfft().backward(coeff_map.complex_map()) else: gradient_map = manager.cfft().backward(coeff_map.complex_map()) time_fft = time_fft.elapsed() time_sampling = user_plus_sys_time() self._results.sampling( scatterers=xray_structure.scatterers(), u_iso_refinable_params=u_iso_refinable_params, scattering_type_registry=xray_structure.scattering_type_registry(), site_symmetry_table=xray_structure.site_symmetry_table(), ft_d_target_d_f_calc=gradient_map, n_parameters=n_parameters, sampled_density_must_be_positive=manager. sampled_density_must_be_positive()) time_sampling = time_sampling.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_or_to_map, time_apply_u_extra=time_apply_u_extra) self.d_target_d_site_frac_was_used = False self.d_target_d_u_star_was_used = False global_counters.gradients_fft.process(time_all.elapsed())
def __init__(self, xray_structure, u_iso_refinable_params, miller_set, d_target_d_f_calc, n_parameters, manager=None, cos_sin_table=False): time_all = user_plus_sys_time() gradients_base.__init__(self, manager, xray_structure, miller_set, algorithm="direct") self._d_target_d_f_calc = d_target_d_f_calc 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_gradients_direct( self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), u_iso_refinable_params, self._xray_structure.scattering_type_registry(), self._xray_structure.site_symmetry_table(), d_target_d_f_calc, n_parameters) else: self._results = ext.structure_factors_gradients_direct( cos_sin_table, self._miller_set.unit_cell(), self._miller_set.space_group(), self._miller_set.indices(), self._xray_structure.scatterers(), u_iso_refinable_params, self._xray_structure.scattering_type_registry(), self._xray_structure.site_symmetry_table(), d_target_d_f_calc, n_parameters) if (manager is not None): manager.estimate_time_direct.register( xray_structure.scatterers().size() * miller_set.indices().size(), timer.elapsed()) self.d_target_d_site_cart_was_used = False self.d_target_d_u_cart_was_used = False global_counters.gradients_direct.process(time_all.elapsed())