Author: bugman Date: Thu Jul 8 11:49:35 2010 New Revision: 11292 URL: http://svn.gna.org/viewcvs/relax?rev=11292&view=rev Log: Better support for the optimisation and mapping of the Ln3+ position. The position is now treated in Angstrom, and is properly scaled. A few additional API methods have been added for the mapping of the optimisation space, and a few modified to support the Ln3+ position. Modified: 1.3/specific_fns/n_state_model.py Modified: 1.3/specific_fns/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/n_state_model.py?rev=11292&r1=11291&r2=11292&view=diff ============================================================================== --- 1.3/specific_fns/n_state_model.py (original) +++ 1.3/specific_fns/n_state_model.py Thu Jul 8 11:49:35 2010 @@ -61,6 +61,7 @@ # Place methods into the API. self.overfit_deselect = self._overfit_deselect_dummy + self.return_conversion_factor = self._return_no_conversion_factor self.test_grid_ops = self._test_grid_ops_general @@ -175,16 +176,20 @@ if ('rdc' in data_types or 'pcs' in data_types) and not (hasattr(cdp.align_tensors, 'fixed') and cdp.align_tensors.fixed): pop_start = pop_start + 5*len(cdp.align_ids) + # The alignment parameters. + for i in range(5*len(cdp.align_ids)): + scaling_matrix[i, i] = 1e-4 + # Loop over the populations, and set the scaling factor. if cdp.model in ['2-domain', 'population']: - factor = 100.0 + factor = 0.1 for i in xrange(pop_start, pop_start + (cdp.N-1)): scaling_matrix[i, i] = factor # The paramagnetic centre. if hasattr(cdp, 'paramag_centre_fixed') and not cdp.paramag_centre_fixed: for i in range(-3, 0): - scaling_matrix[i, i] = 1e10 + scaling_matrix[i, i] = 1e2 # Return the matrix. return scaling_matrix @@ -1674,8 +1679,8 @@ # The paramagnetic centre. elif hasattr(cdp, 'paramag_centre_fixed') and not cdp.paramag_centre_fixed and (n - i) <= 3: - lower.append(-100e-10) - upper.append(100e-10) + lower.append(-100) + upper.append(100) # Otherwise this must be an alignment tensor component. else: @@ -1683,7 +1688,7 @@ upper.append(1e-3) # Minimisation. - self.minimise(min_algor='grid', min_options=[inc, lower, upper], constraints=constraints, verbosity=verbosity, sim_index=sim_index) + self.minimise(min_algor='grid', lower=lower, upper=upper, inc=inc, constraints=constraints, verbosity=verbosity, sim_index=sim_index) def is_spin_param(self, name): @@ -1701,6 +1706,22 @@ # All other parameters are global. return False + + + def map_bounds(self, param, spin_id=None): + """Create bounds for the OpenDX mapping function. + + @param param: The name of the parameter to return the lower and upper bounds of. + @type param: str + @param spin_id: The spin identification string (unused). + @type spin_id: None + @return: The upper and lower bounds of the parameter. + @rtype: list of float + """ + + # Paramagnetic centre. + if search('^paramag_[xyz]$', param): + return [-100.0, 100.0] def minimise(self, min_algor=None, min_options=None, func_tol=None, grad_tol=None, max_iterations=None, constraints=False, scaling=True, verbosity=0, sim_index=None, lower=None, upper=None, inc=None): @@ -1767,7 +1788,14 @@ # Grid search. if search('^[Gg]rid', min_algor): - results = grid(func=model.func, args=(), num_incs=min_options[0], lower=min_options[1], upper=min_options[2], A=A, b=b, verbosity=verbosity) + # Scaling. + if scaling: + for i in xrange(len(param_vector)): + lower[i] = lower[i] / scaling_matrix[i, i] + upper[i] = upper[i] / scaling_matrix[i, i] + + # The search. + results = grid(func=model.func, args=(), num_incs=inc, lower=lower, upper=upper, A=A, b=b, verbosity=verbosity) # Unpack the results. param_vector, func, iter_count, warning = results @@ -2043,6 +2071,23 @@ obj = getattr(cdp, obj_name) obj[index] = value[i] + # The paramagnetic centre. + if search('^paramag_[xyz]$', obj_name): + # Init. + if not hasattr(cdp, 'paramagnetic_centre'): + cdp.paramagnetic_centre = zeros(3, float64) + + # Set the coordinate. + if obj_name == 'paramag_x': + index = 0 + elif obj_name == 'paramag_y': + index = 1 + else: + index = 2 + + # Set the value in Angstrom. + cdp.paramagnetic_centre[index] = value[i] + # Set the spin parameters. else: for spin in spin_loop(spin_id):