def sobol_setup(max_num=200, oversample=100): """Oversampling setup for the quasi-random Sobol' sequence used for numerical PCS integration. @keyword max_num: The maximum number of integration points N. @type max_num: int @keyword oversample: The oversampling factor Ov used for the N * Ov * 10**M, where M is the number of dimensions or torsion-tilt angles for the system. @type oversample: int """ # Test if the current data pipe exists. check_pipe() # Throw a warning to the user if not enough points are being used. if max_num < 200: warn( RelaxWarning( "To obtain reliable results in a frame order analysis, the maximum number of integration points should be greater than 200." )) # Store the values. cdp.sobol_max_points = max_num cdp.sobol_oversample = oversample # Count the number of Sobol' points for the current model. count_sobol_points()
def sobol_setup(max_num=200, oversample=100): """Oversampling setup for the quasi-random Sobol' sequence used for numerical PCS integration. @keyword max_num: The maximum number of integration points N. @type max_num: int @keyword oversample: The oversampling factor Ov used for the N * Ov * 10**M, where M is the number of dimensions or torsion-tilt angles for the system. @type oversample: int """ # Test if the current data pipe exists. check_pipe() # Throw a warning to the user if not enough points are being used. if max_num < 200: warn( RelaxWarning( "To obtain reliable results in a frame order analysis, the maximum number of integration points should be greater than 200." ) ) # Store the values. cdp.sobol_max_points = max_num cdp.sobol_oversample = oversample # Count the number of Sobol' points for the current model. count_sobol_points()
def calculate(self, spin_id=None, scaling_matrix=None, verbosity=1, sim_index=None): """Calculate the chi-squared value for the current parameter values. @keyword spin_id: The spin identification string (unused). @type spin_id: None @keyword scaling_matrix: The per-model list of diagonal and square scaling matrices. @type scaling_matrix: list of numpy rank-2, float64 array or list of None @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. @type verbosity: int @keyword sim_index: The optional MC simulation index (unused). @type sim_index: None or int """ # Set up the data structures for the target function. param_vector, full_tensors, full_in_ref_frame, rdcs, rdc_err, rdc_weight, rdc_vect, rdc_const, pcs, pcs_err, pcs_weight, atomic_pos, temp, frq, paramag_centre, com, ave_pos_pivot, pivot, pivot_opt = target_fn_data_setup(sim_index=sim_index, verbosity=verbosity, unset_fail=True) # The numeric integration information. if not hasattr(cdp, 'quad_int'): cdp.quad_int = False sobol_max_points, sobol_oversample = None, None if hasattr(cdp, 'sobol_max_points'): sobol_max_points = cdp.sobol_max_points sobol_oversample = cdp.sobol_oversample # Set up the optimisation target function class. target_fn = frame_order.Frame_order(model=cdp.model, init_params=param_vector, full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, pivot_opt=pivot_opt, sobol_max_points=sobol_max_points, sobol_oversample=sobol_oversample, quad_int=cdp.quad_int) # Make a single function call. This will cause back calculation and the data will be stored in the class instance. chi2 = target_fn.func(param_vector) # Set the chi2. cdp.chi2 = chi2 # Store the back-calculated data. store_bc_data(A_5D_bc=target_fn.A_5D_bc, pcs_theta=target_fn.pcs_theta, rdc_theta=target_fn.rdc_theta) # Feedback on the number of integration points used. if not cdp.quad_int: count_sobol_points(target_fn=target_fn, verbosity=verbosity) # Printout. if verbosity: print("Chi2: %s" % chi2)
def calculate(self, spin_id=None, scaling_matrix=None, verbosity=1, sim_index=None): """Calculate the chi-squared value for the current parameter values. @keyword spin_id: The spin identification string (unused). @type spin_id: None @keyword scaling_matrix: The per-model list of diagonal and square scaling matrices. @type scaling_matrix: list of numpy rank-2, float64 array or list of None @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. @type verbosity: int @keyword sim_index: The optional MC simulation index (unused). @type sim_index: None or int """ # Set up the data structures for the target function. param_vector, full_tensors, full_in_ref_frame, rdcs, rdc_err, rdc_weight, rdc_vect, rdc_const, pcs, pcs_err, pcs_weight, atomic_pos, temp, frq, paramag_centre, com, ave_pos_pivot, pivot, pivot_opt = target_fn_data_setup( sim_index=sim_index, verbosity=verbosity, unset_fail=True) # The numeric integration information. if not hasattr(cdp, 'quad_int'): cdp.quad_int = False sobol_max_points, sobol_oversample = None, None if hasattr(cdp, 'sobol_max_points'): sobol_max_points = cdp.sobol_max_points sobol_oversample = cdp.sobol_oversample # Set up the optimisation target function class. target_fn = frame_order.Frame_order( model=cdp.model, init_params=param_vector, full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, pivot_opt=pivot_opt, sobol_max_points=sobol_max_points, sobol_oversample=sobol_oversample, quad_int=cdp.quad_int) # Make a single function call. This will cause back calculation and the data will be stored in the class instance. chi2 = target_fn.func(param_vector) # Set the chi2. cdp.chi2 = chi2 # Store the back-calculated data. store_bc_data(A_5D_bc=target_fn.A_5D_bc, pcs_theta=target_fn.pcs_theta, rdc_theta=target_fn.rdc_theta) # Feedback on the number of integration points used. if not cdp.quad_int: count_sobol_points(target_fn=target_fn, verbosity=verbosity) # Printout. if verbosity: print("Chi2: %s" % chi2)