def constrain_atom(self, atom, to='F', axis='all'): "修改某一类型原子的FT信息" # [1, 1, 1, 16] -> [0, 1, 2, 3, 19] idx_list = [ sum(self.atoms_num[:i]) for i in range(1, len(self.atoms) + 1) ] idx_list = [0] + idx_list if to not in ['T', 'F']: raise CarfileValueError('Variable to must be T or F.') for atomtype, idx, next_idx in \ zip(self.atoms, idx_list[:-1], idx_list[1:]): if atomtype == atom: if axis in ['x', 'X']: self.tf[idx:next_idx, 0] = to elif axis in ['y', 'Y']: self.tf[idx:next_idx, 1] = to elif axis in ['z', 'Z']: self.tf[idx:next_idx, 2] = to else: self.tf[idx:next_idx, :] = to break return self.tf
def verify(self): if len(self.data) != self.ntot: raise CarfileValueError('Atom numbers mismatch!')