Author: bugman Date: Wed Jan 23 22:55:07 2013 New Revision: 18288 URL: http://svn.gna.org/viewcvs/relax?rev=18288&view=rev Log: Merged revisions 18279-18287 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r18279 | bugman | 2013-01-23 18:51:33 +0100 (Wed, 23 Jan 2013) | 3 lines Simplified the parameter unpacking in the func_standard() N-state model target function. ........ r18280 | bugman | 2013-01-23 21:08:23 +0100 (Wed, 23 Jan 2013) | 3 lines Improved the comments in the _disassemble_param_vector() N-state model method. ........ r18281 | bugman | 2013-01-23 21:09:49 +0100 (Wed, 23 Jan 2013) | 6 lines Modified the populations.py N-state model system test script to better test optimisation. The probability of the 2nd state has been slightly shifted to make sure the original value can be found. ........ r18282 | bugman | 2013-01-23 21:35:53 +0100 (Wed, 23 Jan 2013) | 5 lines Bug fix for the N-state model Hessian d2func_standard() method. An index variable name was incorrect causing the population model to fail with Newton optimisation. ........ r18283 | bugman | 2013-01-23 21:38:05 +0100 (Wed, 23 Jan 2013) | 5 lines Modified the metal_pos_opt.py N-state model system test script to demonstrate some failures. This change also caught the bug fixed in r18282. ........ r18284 | bugman | 2013-01-23 21:41:08 +0100 (Wed, 23 Jan 2013) | 3 lines Improved the checks of the metal_pos_opt.py N-state model system test script. ........ r18285 | bugman | 2013-01-23 22:12:42 +0100 (Wed, 23 Jan 2013) | 5 lines Bug fixes for the _opt_uses_pcs() and _opt_uses_rdc() N-state model methods. These now check that the populations are optimised as well. ........ r18286 | bugman | 2013-01-23 22:14:19 +0100 (Wed, 23 Jan 2013) | 3 lines Modified the metal_pos_opt.py N-state model system test script to catch yet another bug. ........ r18287 | bugman | 2013-01-23 22:51:13 +0100 (Wed, 23 Jan 2013) | 6 lines Fix for a bug caught by the N_state_model.test_metal_pos_opt system test. The problem was that uninitalised probability arrays of None from cdp.probs was always sent into the target function, whereas None should be sent in instead. ........ Modified: branches/frame_order_testing/ (props changed) branches/frame_order_testing/maths_fns/n_state_model.py branches/frame_order_testing/specific_fns/n_state_model.py branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/metal_pos_opt.py branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/populations.py Propchange: branches/frame_order_testing/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Wed Jan 23 22:55:07 2013 @@ -1,1 +1,1 @@ -/trunk:1-18277 +/trunk:1-18287 Modified: branches/frame_order_testing/maths_fns/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/maths_fns/n_state_model.py?rev=18288&r1=18287&r2=18288&view=diff ============================================================================== --- branches/frame_order_testing/maths_fns/n_state_model.py (original) +++ branches/frame_order_testing/maths_fns/n_state_model.py Wed Jan 23 22:55:07 2013 @@ -638,21 +638,17 @@ # Initial chi-squared (or SSE) value. chi2_sum = 0.0 - # Unpack both the probabilities and paramagnetic centre. + # Unpack both the probabilities (when the paramagnetic centre is also optimised). if not self.probs_fixed and not self.centre_fixed: # The probabilities. self.probs = params[-(self.N-1)-3:-3] - # The position (also update the paramagnetic info). - self.paramag_centre = params[-3:] - self.paramag_info() - # Unpack the probabilities (located at the end of the parameter array). elif not self.probs_fixed: self.probs = params[-(self.N-1):] # Unpack the paramagnetic centre (also update the paramagnetic info). - elif not self.centre_fixed: + if not self.centre_fixed: self.paramag_centre = params[-3:] self.paramag_info() @@ -1126,20 +1122,20 @@ # Calculate the RDC Hessian component. for j in range(self.num_interatom): if self.fixed_tensors[align_index] and self.rdc_flag[align_index] and not self.missing_rdc[align_index, j]: - self.d2rdc_theta[pc_index, i*5+0, align_index, j] = self.d2rdc_theta[align_index*5+0, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[0], absolute=self.absolute_rdc[align_index, j]) - self.d2rdc_theta[pc_index, i*5+1, align_index, j] = self.d2rdc_theta[align_index*5+1, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[1], absolute=self.absolute_rdc[align_index, j]) - self.d2rdc_theta[pc_index, i*5+2, align_index, j] = self.d2rdc_theta[align_index*5+2, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[2], absolute=self.absolute_rdc[align_index, j]) - self.d2rdc_theta[pc_index, i*5+3, align_index, j] = self.d2rdc_theta[align_index*5+3, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[3], absolute=self.absolute_rdc[align_index, j]) - self.d2rdc_theta[pc_index, i*5+4, align_index, j] = self.d2rdc_theta[align_index*5+4, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[4], absolute=self.absolute_rdc[align_index, j]) + self.d2rdc_theta[pc_index, align_index*5+0, align_index, j] = self.d2rdc_theta[align_index*5+0, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[0], absolute=self.absolute_rdc[align_index, j]) + self.d2rdc_theta[pc_index, align_index*5+1, align_index, j] = self.d2rdc_theta[align_index*5+1, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[1], absolute=self.absolute_rdc[align_index, j]) + self.d2rdc_theta[pc_index, align_index*5+2, align_index, j] = self.d2rdc_theta[align_index*5+2, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[2], absolute=self.absolute_rdc[align_index, j]) + self.d2rdc_theta[pc_index, align_index*5+3, align_index, j] = self.d2rdc_theta[align_index*5+3, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[3], absolute=self.absolute_rdc[align_index, j]) + self.d2rdc_theta[pc_index, align_index*5+4, align_index, j] = self.d2rdc_theta[align_index*5+4, pc_index, align_index, j] = rdc_tensor(self.dip_const[j], self.dip_vect[j, c], self.dA[4], absolute=self.absolute_rdc[align_index, j]) # Calculate the PCS Hessian component. for j in range(self.num_spins): if self.fixed_tensors[align_index] and self.pcs_flag[align_index] and not self.missing_deltaij[align_index, j]: - self.d2deltaij_theta[pc_index, i*5+0, align_index, j] = self.d2deltaij_theta[align_index*5+0, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[0]) - self.d2deltaij_theta[pc_index, i*5+1, align_index, j] = self.d2deltaij_theta[align_index*5+1, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[1]) - self.d2deltaij_theta[pc_index, i*5+2, align_index, j] = self.d2deltaij_theta[align_index*5+2, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[2]) - self.d2deltaij_theta[pc_index, i*5+3, align_index, j] = self.d2deltaij_theta[align_index*5+3, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[3]) - self.d2deltaij_theta[pc_index, i*5+4, align_index, j] = self.d2deltaij_theta[align_index*5+4, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[4]) + self.d2deltaij_theta[pc_index, align_index*5+0, align_index, j] = self.d2deltaij_theta[align_index*5+0, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[0]) + self.d2deltaij_theta[pc_index, align_index*5+1, align_index, j] = self.d2deltaij_theta[align_index*5+1, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[1]) + self.d2deltaij_theta[pc_index, align_index*5+2, align_index, j] = self.d2deltaij_theta[align_index*5+2, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[2]) + self.d2deltaij_theta[pc_index, align_index*5+3, align_index, j] = self.d2deltaij_theta[align_index*5+3, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[3]) + self.d2deltaij_theta[pc_index, align_index*5+4, align_index, j] = self.d2deltaij_theta[align_index*5+4, pc_index, align_index, j] = pcs_tensor(self.pcs_const[align_index, j, c], self.paramag_unit_vect[j, c], self.dA[4]) # Construct the paramagnetic centre c partial derivative components for the PCS. if not self.centre_fixed: Modified: branches/frame_order_testing/specific_fns/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/specific_fns/n_state_model.py?rev=18288&r1=18287&r2=18288&view=diff ============================================================================== --- branches/frame_order_testing/specific_fns/n_state_model.py (original) +++ branches/frame_order_testing/specific_fns/n_state_model.py Wed Jan 23 22:55:07 2013 @@ -580,7 +580,7 @@ # Create a new parameter vector without the tensors. param_vector = param_vector[5*tensor_num:] - # Monte Carlo simulation data structures. + # Alias the Monte Carlo simulation data structures. if sim_index != None: # Populations. if cdp.model in ['2-domain', 'population']: @@ -592,7 +592,7 @@ beta = cdp.beta_sim[sim_index] gamma = cdp.gamma_sim[sim_index] - # Normal data structures. + # Alias the normal data structures. else: # Populations. if cdp.model in ['2-domain', 'population']: @@ -604,7 +604,7 @@ beta = cdp.beta gamma = cdp.gamma - # The probabilities for states 0 to N-1. + # Set the probabilities for states 0 to N-1 in the aliased structures. if cdp.model in ['2-domain', 'population']: for i in range(cdp.N-1): probs[i] = param_vector[i] @@ -612,7 +612,7 @@ # The probability for state N. probs[-1] = 1 - sum(probs[0:-1]) - # The Euler angles. + # Set the Euler angles in the aliased structures. if cdp.model == '2-domain': for i in range(cdp.N): alpha[i] = param_vector[cdp.N-1 + 3*i] @@ -1422,8 +1422,13 @@ if hasattr(cdp, 'paramag_centre_fixed') and not cdp.paramag_centre_fixed: pos_flag = True + # Are the populations optimised? + prob_flag = False + if cdp.model == 'population': + prob_flag = True + # Not used. - if not tensor_flag and not pos_flag: + if not tensor_flag and not pos_flag and not prob_flag: return False # The PCS data is to be used for optimisation. @@ -1455,8 +1460,13 @@ if hasattr(cdp, 'paramag_centre_fixed') and not cdp.paramag_centre_fixed: pos_flag = True + # Are the populations optimised? + prob_flag = False + if cdp.model == 'population': + prob_flag = True + # Not used. - if not tensor_flag and not pos_flag: + if not tensor_flag and not pos_flag and not prob_flag: return False # The RDC data is to be used for optimisation. @@ -1627,7 +1637,7 @@ # The probabilities. probs = None - if hasattr(cdp, 'probs'): + if hasattr(cdp, 'probs') and len(cdp.probs) and cdp.probs[0] != None: probs = cdp.probs # Diagonal scaling. Modified: branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/metal_pos_opt.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/metal_pos_opt.py?rev=18288&r1=18287&r2=18288&view=diff ============================================================================== --- branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/metal_pos_opt.py (original) +++ branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/metal_pos_opt.py Wed Jan 23 22:55:07 2013 @@ -115,7 +115,20 @@ # Optimise the Ln3+ position. x, y, z = cdp.paramagnetic_centre -#self._execute_uf(uf_name='n_state_model.select_model', model='population') +self._execute_uf(uf_name='n_state_model.select_model', model='population') +self._execute_uf(uf_name='calc') +print("Chi2: %s" % cdp.chi2) +chi2 = cdp.chi2 +if cdp.chi2 < 1e-15: + raise RelaxError("The chi2 value cannot be zero here!") +self._execute_uf(uf_name='paramag.centre', fix=True) +self._execute_uf(uf_name='calc') +print("Chi2: %s" % cdp.chi2) +if abs(cdp.chi2 - chi2) > 1e-15: + raise RelaxError("The chi2 value must match the previous value of %s." % chi2) +self._execute_uf(uf_name='n_state_model.select_model', model='fixed') +self._execute_uf(uf_name='paramag.centre', fix=False) +self._execute_uf(uf_name='calc') self._execute_uf('bfgs', constraints=False, max_iter=500, uf_name='minimise', verbosity=1) # Check that the metal moved. Modified: branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/populations.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/populations.py?rev=18288&r1=18287&r2=18288&view=diff ============================================================================== --- branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/populations.py (original) +++ branches/frame_order_testing/test_suite/system_tests/scripts/n_state_model/populations.py Wed Jan 23 22:55:07 2013 @@ -109,8 +109,11 @@ # The population model opt. ########################### +# Change a probability +self._execute_uf(uf_name='value.set', val=0.6005, param='p1') + # Minimisation. -self._execute_uf(uf_name='minimise', min_algor='sd', func_tol=1e-2) +self._execute_uf(uf_name='minimise', min_algor='bfgs') # Write out a results file. self._execute_uf(uf_name='results.write', file='devnull', force=True)