gparse.m

From Spinach Documentation Wiki
Revision as of 06:55, 30 August 2026 by Kuprov (talk | contribs) (sync with Spinach main f053e432: Gaussian 16 support, updated route keywords, new output fields (k_couplings, isotopes, charge, el_dip_std, multiplicity), Fermi contact 2S normalisation note)
Jump to: navigation, search

A parser for Gaussian (03, 09, 16) calculation logs. The function extracts all potentially useful information from the Gaussian log. The following keywords must be added to the route section of the Gaussian input file to produce a useful log:

    #p nmr=(giao,spinspin,susceptibility) 
       output=pickett pop=minimal IOp(6/82=1)

Examples of complete Gaussian input files that perform geometry optimisation followed by magnetic properties calculations may be downloaded here, here, and here. Some real-life Gaussian logs that may be used for practice with data import are given in examples/standard_systems directory.

Syntax

    props=gparse(filename,options)

Parameters

    filename - the name of the file to be parsed, a character string

    options  - a cell array of character strings. By default
               all interaction tensors are symmetrised; the
               symmetrisation may be turned off by adding the
               following strings:

               'g_nosymm'   - turns off g-tensor symmetrisation

               'cst_nosymm' - turns off shielding tensor symmetrisation

               'hfc_nosymm' - turns off hyperfine tensor symmetrisation 

Returns

The following output fields are returned, if the corresponding information is present in the log file:

    props.inp_geom         - input geometry, natoms x 3 array, Angstrom

    props.std_geom         - standard geometry, natoms x 3 array, Angstrom

    props.natoms           - number of atoms, an integer

    props.method           - model chemistry Gaussian had used, e.g. 'B3LYP'

    props.energy           - SCF energy, Hartree

    props.hfc.iso          - isotropic hyperfine couplings, natoms x 1 array, Gauss

    props.hfc.full.eigvals - HFC eigenvalues, natoms x 1 cell array of 3-vectors, Gauss

    props.hfc.full.eigvecs - HFC eigenvectors, natoms x 1 cell array of 3x3 matrices

    props.hfc.full.matrix  - HFC tensors, natoms x 1 cell array of 3x3 matrices, Gauss

    props.g_tensor.eigvecs - g-tensor eigenvectors, 3x3 matrix

    props.g_tensor.eigvals - g-tensor eigenvalues, 3-vector, Bohr magneton units

    props.g_tensor.matrix  - g-tensor, 3x3 matrix, Bohr magneton units

    props.cst              - absolute shielding tensors, natoms x 1 cell array of 3x3 matrices, ppm relative to bare nucleus in vacuum

    props.k_couplings      - isotropic K-couplings, Hz

    props.j_couplings      - isotropic J-couplings, nspins x nspins matrix, Hz

    props.srt              - spin-rotation tensor, nspins x 1 cell array of 3x3 matrices, Hz

    props.nqi              - nuclear quadrupole interaction tensors, nspins x 1 cell array of 3x3 matrices, Hz

    props.chi              - magnetic susceptibility tensor, 3x3 matrix, cubic Angstroms

    props.gibbs            - Gibbs free energy, Hartree

    props.symbols          - atomic symbols, nspins x 1 cell array of character strings

    props.isotopes         - nuclear isotopes used by Gaussian

    props.atomic_numbers   - atomic numbers, nspins x 1 array of integers

    props.charge           - overall charge

    props.el_dip_std       - electric dipole moment, Debye

    props.multiplicity     - overall multiplicity

    props.filename         - log file name, a character string

    props.error            - set to true if the calculation contains an error of any type

Examples

A typical example of a Spinach input that uses data import from a Gaussian log appears below.

    % Read the spin system properties (vacuum DFT calculation)
    options.min_j=1.0;
    [sys,inter]=g2spinach(gparse('../standard_systems/sucrose.log'),{ {'H','1H'} },31.8,options);
    
    % Magnet field
    sys.magnet=14.1;
    
    % Basis set
    bas.formalism='sphten-liouv';
    bas.approximation='IK-2';
    bas.connectivity='scalar_couplings';
    bas.space_level=2;
    
    % Relaxation theory parameters
    inter.relaxation={'redfield'};
    inter.rlx_keep='secular';
    inter.tau_c=1e-9;
    
    % Spinach housekeeping
    spin_system=create(sys,inter);
    spin_system=basis(spin_system,bas);
    
    % Sequence parameters
    parameters.spins={'1H'};
    parameters.rho0=state(spin_system,'L+','1H','cheap');
    parameters.coil=state(spin_system,'L+','1H','cheap');
    parameters.decouple={};
    parameters.offset=1800;
    parameters.sweep=5000;
    parameters.npoints=8192;
    parameters.zerofill=65536;
    parameters.axis_units='ppm';
    parameters.invert_axis=1;
    
    % Simulation
    fid=liquid(spin_system,@acquire,parameters,'nmr');
    
    % Apodization
    fid=apodization(fid,'crisp-1d');
    
    % Fourier transform
    spectrum=fftshift(fft(fid,parameters.zerofill));
    
    % Plotting
    plot_1d(spin_system,real(spectrum),parameters);

Further examples of Gaussian inputs: gaussian_a.txt, gaussian_b.txt, gaussian_c.txt - note that the extra printing flag (#p) should always be present.

Notes

  1. Gaussian prints all anisotropic quantities relative to what it calls "standard orientation". Do not use the "input orientation", that would be wrong.
  2. Do not instruct Gaussian to print eigenvectors of shielding tensors (nmr=printeigenvectors): that option has a bug that makes the eigenvectors refer to the symmetric part of the shielding tensor. Eigenvectors are not necessary anyway - the relevant orientation information is already contained in the shielding tensor matrix.
  3. Chemical shielding is not the same as chemical shift.
  4. Spin-rotation tensors are imported, but not used anywhere in Spinach at the moment.
  5. Hyperfine tensors are imported in Gauss because Gauss units do not depend on the electron g-tensor.
  6. Gaussian divides its isotropic Fermi contact couplings by 2S=multiplicity-1, but prints the anisotropic spin dipole couplings without that normalisation; the two blocks therefore disagree by 2S for anything above a doublet. This is corrected here, and the hyperfine tensors returned are the ones that enter the spin Hamiltonian as S*A*I, in agreement with oparse.m.
  7. This function parses Gaussian logs. Use g2spinach.m to convert that information into Spinach input structures.
  8. The parser is a bit old-school. If you are proficient with regular expressoins, we would really appreciate a hand.

See also

oparse.m, g2spinach.m, cst_display.m, hfc_display.m, molplot.m, c2spinach.m, cyprinol.m, fatty_acid.m, gissmo2spinach.m, karplus_fit.m, killcross.m, killdiag.m, merge_inp.m, methyl_group.m, nuclacid.m, ocparse.m, parsexml.m, protein.m, read_bmrb.m, read_pdb_nuc.m, read_pdb_pro.m, v2spinach.m, weblab2nqi.m, x2spinach.m, Import,_export,_and_visualisation

Version 2.2, authors: Ilya Kuprov, Gareth Charnock, Jennifer Handsel, Luke Ward