Author image Ivan Tubert-Brohman


Chemistry::File::Mopac - MOPAC 6 input file reader/writer


    use Chemistry::File::Mopac;

    # read a MOPAC file
    my $mol = Chemistry::Mol->read('file.mop');

    # write a MOPAC file using cartesian coordinates
    $mol->write('file.mop', coords => 'cartesian');

    # now with internal coordinates
    $mol->write('file.mop', coords => 'internal');

    # rebuild the Z-matrix from scratch while we are at it
    $mol->write('file.mop', rebuild => 1);


This module reads and writes MOPAC 6 input files. It can handle both internal coordinates and cartesian coordinates. It also extracts molecules from summary files, defined as those files that match /SUMMARY OF/ in the third line. Perhaps a future version will extract additional information such as the energy and dipole from the summary file.

This module registers the mop format with Chemistry::Mol. For detection purposes, it assumes that filenames ending in .mop or .zt have the Mopac format, as well as files whose first line matches /am1|pm3|mndo|mdg|pdg/i (this may change in the future).

When the module reads an input file into $mol, it puts the keywords (usually the first line of the file) in $mol->attr("mopac/keywords"), the comments (usually everything else on the first three lines) in $mol->attr("mopac/comments") and $mol->name, and the internal coordinates for each atom in $atom->internal_coords.

When writing, the kind of coordinates used depend on the coords option, as shown in the SYNOPSIS. Internal coordinates are used by default. If the molecule has no internal coordinates defined or the rebuild option is set, the build_zmat function from Chemistry::InternalCoords::Builder is used to renumber the atoms and build the Z-matrix from scratch.


When writing a Mopac file, this version marks all coordinates as variable (for the purpose of geometry optimization by Mopac). A future version should have more flexibility.




Chemistry::Mol, Chemistry::File, Chemistry::InternalCoords, Chemistry::InternalCoords::Builder,


Ivan Tubert-Brohman <>


Copyright (c) 2004 Ivan Tubert. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.