# gparse.m

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A parser for Gaussian03 and Gaussian09 calculation logs. The function extracts all potentially useful information from the Gaussian log. The following sections must be added to the route section of the Gaussian03/9 input file to produce a useful log:

    #p nmr=(giao,spinspin,susceptibility) output=pickett


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)


## Arguments

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

options  - a cell array of character strongs, the following:

'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.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.atomic_numbers   - atomic numbers, nspins x 1 array of integers

props.filename         - log file name, a character string

props.error            - set to 1 if the log contains an error message


## 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 geometry".
2. Chemical shielding is not the same as chemical shift.
3. Spin-rotation tensors are imported, but not used anywhere in Spinach at the moment.
4. Hyperfine tensors are imported in Gauss because Gauss units do not depend on the electron g-tensor.
5. This function parses Gaussian logs. Use g2spinach.m to convert that information into Spinach input structures.
6. The parser is a bit old-school. If you are proficient with regular expressoins, we would really appreciate a hand.