def parse_molcas(file_path, momatrix=None, overlap=None, occvec=None, density=None, **kwargs): """ Will parse a Molcas output file. Optionally it will attempt to parse additional information obtained from the same directory from specified Orb files or the AO overlap matrix and density matrix. If density keyword is specified, the momatrix keyword is ignored. Args file_path (str): Path to output file momatrix (str): file name of the C matrix of interest overlap (str): file name of the overlap matrix density (str): file name of the density matrix Returns parsed (Editor): contains many attributes similar to the exatomic universe """ uni1 = Output(file_path, **kwargs) dirtree = sep.join(file_path.split(sep)[:-1]) if density is not None: fp = sep.join([dirtree, density]) if os.path.isfile(fp): dens = DensityMatrix(_parse_ovl(fp)) uni1.density = dens else: print('Is {} in the same directory as {}?'.format(density, file_path)) if momatrix is not None and density is None: fp = sep.join([dirtree, momatrix]) if os.path.isfile(fp): orbs = Orb(fp) orbs.parse_momatrix() if occvec is not None: dens = DensityMatrix.from_momatrix(orbs.momatrix, occvec) else: dens = DensityMatrix.from_momatrix(orbs.momatrix, orbs.occupation_vector) uni1.momatrix = orbs.momatrix uni1.occupation_vector = orbs.occupation_vector uni1.density = dens else: print('Is {} in the same directory as {}?'.format(momatrix, file_path)) if overlap is not None: fp = sep.join([dirtree, overlap]) if os.path.isfile(fp): ovl = _parse_ovl(fp) uni1.overlap = ovl else: print('Is {} in the same directory as {}?'.format(overlap, file_path)) return uni1
def compute_density(self): """Compute density from momatrix and occupation vector.""" if not hasattr(self, 'occupation_vector'): raise Exception('Universe must have momatrix and occupation_vector attributes') self.density = DensityMatrix.from_momatrix(self.momatrix, self.occupation_vector)