def _write(gobj, gtensor, title, level=logger.INFO): if gobj.verbose >= level: w, v = numpy.linalg.eigh(numpy.dot(gtensor, gtensor.T)) idxmax = abs(v).argmax(axis=0) v[:, v[idxmax, [0, 1, 2]] < 0] *= -1 # format phase sorted_axis = numpy.argsort(idxmax) v = v[:, sorted_axis] if numpy.linalg.det(v) < 0: # ensure new axes in RHS v[:, 2] *= -1 g2 = reduce(numpy.dot, (v.T, gtensor, v)) gobj.stdout.write('%s %s\n' % (title, g2.diagonal())) if gobj.verbose >= logger.DEBUG: rhf_nmr._write(gobj.stdout, gtensor, title + ' tensor')
def _write(gobj, gtensor, title): gobj.stdout.write('%s %s\n' % (title, gtensor.diagonal())) if gobj.verbose >= logger.DEBUG: rhf_nmr._write(gobj.stdout, gtensor, title+' tensor') w = numpy.linalg.svd(gtensor)[1] gobj.stdout.write('sqrt(ggT) %s\n' % w)
def _write(obj, tensor, title): obj.stdout.write('%s %s\n' % (title, tensor.diagonal())) rhf_nmr._write(obj.stdout, tensor, title + ' tensor') w = numpy.linalg.eigvals(tensor) obj.stdout.write('eigenvalues: %s\n' % w)
def shielding(self, mo1=None): cput0 = (time.clock(), time.time()) self.dump_flags() if self.verbose >= logger.WARN: self.check_sanity() t0 = (time.clock(), time.time()) unit_ppm = nist.ALPHA**2 * 1e6 msc_dia = self.dia() * unit_ppm t0 = logger.timer(self, 'h11', *t0) msc_para, para_pos, para_neg, para_occ = \ [x*unit_ppm for x in self.para(mo10=mo1)] e11 = msc_para + msc_dia logger.timer(self, 'NMR shielding', *cput0) if self.verbose > logger.QUIET: for i, atm_id in enumerate(self.shielding_nuc): rhf_nmr._write(self.stdout, e11[i], '\ntotal shielding of atom %d %s' % (atm_id, self.mol.atom_symbol(atm_id))) rhf_nmr._write(self.stdout, msc_dia[i], 'dia-magnetism') rhf_nmr._write(self.stdout, msc_para[i], 'para-magnetism') if self.verbose >= logger.INFO: rhf_nmr._write(self.stdout, para_occ[i], 'occ part of para-magnetism') rhf_nmr._write(self.stdout, para_pos[i], 'vir-pos part of para-magnetism') rhf_nmr._write(self.stdout, para_neg[i], 'vir-neg part of para-magnetism') return e11
def shielding(self, mo1=None): cput0 = (logger.process_clock(), logger.perf_counter()) self.dump_flags() if self.verbose >= logger.WARN: self.check_sanity() t0 = (logger.process_clock(), logger.perf_counter()) unit_ppm = nist.ALPHA**2 * 1e6 msc_dia = self.dia() * unit_ppm t0 = logger.timer(self, 'h11', *t0) msc_para, para_pos, para_neg, para_occ = \ [x*unit_ppm for x in self.para(mo10=mo1)] e11 = msc_para + msc_dia logger.timer(self, 'NMR shielding', *cput0) if self.verbose > logger.QUIET: for i, atm_id in enumerate(self.shielding_nuc): rhf_nmr._write( self.stdout, e11[i], '\ntotal shielding of atom %d %s' % (atm_id, self.mol.atom_symbol(atm_id))) rhf_nmr._write(self.stdout, msc_dia[i], 'dia-magnetism') rhf_nmr._write(self.stdout, msc_para[i], 'para-magnetism') if self.verbose >= logger.INFO: rhf_nmr._write(self.stdout, para_occ[i], 'occ part of para-magnetism') rhf_nmr._write(self.stdout, para_pos[i], 'vir-pos part of para-magnetism') rhf_nmr._write(self.stdout, para_neg[i], 'vir-neg part of para-magnetism') return e11
def _write(gobj, gtensor, title): gobj.stdout.write('%s %s\n' % (title, gtensor.diagonal())) if gobj.verbose >= logger.DEBUG: rhf_nmr._write(gobj.stdout, gtensor, title+' tensor') w = numpy.linalg.svd(gtensor)[1] gobj.stdout.write('sqrt(ggT) %s\n' % w)