# IODATA is an input and output module for quantum chemistry.# Copyright (C) 2011-2019 The IODATA Development Team## This file is part of IODATA.## IODATA is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 3# of the License, or (at your option) any later version.## IODATA is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, see <http://www.gnu.org/licenses/># --"""Gaussian input format."""importnumpyasnpfrom..docstringsimportdocument_load_onefrom..periodicimportsym2numfrom..utilsimportLineIterator,LoadError,angstrom__all__=()PATTERNS=["*.com","*.gjf"]
[docs]@document_load_one("Gaussian Input File",["atcoords","atnums","title"],[])defload_one(lit:LineIterator):"""Do not edit this docstring. It will be overwritten."""line=next(lit)# check multiple-link 0 section starts with '%'whileline.startswith(r"%"):line=next(lit)# check multiple-line route sectiondata={}route_line=""whileline.strip():route_line+=" "+line.strip()line=next(lit)route_line=route_line[1:]line=next(lit)title_line=""whileline.strip():title_line+=" "+line.strip()line=next(lit)title_line=title_line[1:]data["title"]=title_line# charge_spin_mult_line_=next(lit)coord_line=next(lit)numbers=[]coordinates=[]whilecoord_line:contents=coord_line.strip().split()ifnotcontents:breakiflen(contents)!=4:raiseLoadError("No Cartesian Structure is detected.",lit)numbers.append(sym2num[contents[0]])coor=list(map(float,contents[1:]))coordinates.append(coor)coord_line=next(lit)data["atnums"]=np.array(numbers)data["atcoords"]=np.array(coordinates)*angstromreturndata