Author: bugman Date: Mon Jun 18 14:48:49 2012 New Revision: 16935 URL: http://svn.gna.org/viewcvs/relax?rev=16935&view=rev Log: Fix for the dipole_pair.define user function - the interatom object can pre-exist, containing other data. Modified: branches/interatomic/generic_fns/dipole_pair.py Modified: branches/interatomic/generic_fns/dipole_pair.py URL: http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/dipole_pair.py?rev=16935&r1=16934&r2=16935&view=diff ============================================================================== --- branches/interatomic/generic_fns/dipole_pair.py (original) +++ branches/interatomic/generic_fns/dipole_pair.py Mon Jun 18 14:48:49 2012 @@ -53,12 +53,19 @@ if direct_bond and hasattr(cdp, 'structure') and not cdp.structure.are_bonded(atom_id1=id1, atom_id2=id2): continue - # No interatomic data container should exist. - if return_interatom(id1, id2): + # Get the interatomic data object, if it exists. + interatom = return_interatom(id1, id2) + + # Check that this has not already been set up. + if hasattr(interatom, 'dipole_pair') and interatom.dipole_pair: raise RelaxError("The magnetic dipole-dipole interaction already exists between the spins '%s' and '%s'." % (id1, id2)) - # Create the container. - create_interatom(spin_id1=id1, spin_id2=id2) + # Create the container if needed. + if not interatom: + interatom = create_interatom(spin_id1=id1, spin_id2=id2) + + # Set a flag indicating that a dipole-dipole interaction is present. + interatom.dipole_pair = True # Store the IDs for the print out. ids.append([repr(id1), repr(id2)])