7
$\begingroup$

I am doing calculations with MOPAC semi-empirical package.

As I have many systems (around 40), extracting the date manually, besides being tiring it can cause errors.

I already worked with ASE, but the data it can extract is very limited.

My question is: Are there available scripts (Bach, Python, etc.) to automatically extract data from MOPAC calculations?

Note: I am thinking in extracting all (or most all) the useful data: heat of formation, molecular orbitals (w/, w/o spin polarization), energies, frequencies, thermochemistry data, forces, etc.

$\endgroup$
11
  • $\begingroup$ Are your data in the list parsable with the cclib python library? $\endgroup$ Commented Jul 5, 2022 at 15:17
  • $\begingroup$ Yes, many of them are there. $\endgroup$
    – Camps
    Commented Jul 5, 2022 at 15:20
  • $\begingroup$ @AndreaPellegrini using the example from cclib page to parse the number of atoms and molecular orbitals, I got error :( $\endgroup$
    – Camps
    Commented Jul 5, 2022 at 15:49
  • 1
    $\begingroup$ I know right now they're debugging the new version, so try to contact them and see if you found a bug $\endgroup$ Commented Jul 6, 2022 at 8:06
  • 2
    $\begingroup$ I don't think it would happen quickly, but it may be worth putting in a request for MOPAC parser to the HORTON/IODATA crew. They have many parsers, but alas, not MOPAC github.com/theochem/iodata/tree/master/iodata/formats $\endgroup$
    – B. Kelly
    Commented Jul 7, 2022 at 13:06

1 Answer 1

3
$\begingroup$

I created the script bellow to extract the data I'm interested in from all MOPAC out files put inside a given folder and create a CSV file with all the data:

#!/bin/sh
#script to extract information from the output MOPAC file
#Use:
# ./fromMOPAC.sh folder_name
#
#The folder_name is a folder where all the MOPAC output files (.out) are located. A file with the name of the folder will be created with the data.
#
#

for filename in $1/*.out
do

HeatF=$(grep "FINAL HEAT OF FORMATION =      " $filename | grep '='| awk '{printf "%12.6f \n",$6}')
TotalEnergy=$(grep "TOTAL ENERGY            =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')
DispE=$(grep "DISPERSION ENERGY       =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')
HBondE=$(grep "H-BOND ENERGY           =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')
NHBonds=$(grep "No. OF HYDROGEN BONDS   =" $filename | grep '='| awk '{printf "%12.6f \n",$6}')
IonPot=$(grep "IONIZATION POTENTIAL    =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')
AlphaSOMO=$(grep "ALPHA SOMO LUMO (EV)    =" $filename | grep '='| awk '{printf "%12.6f \n",$6}')
AlphaLUMO=$(grep "ALPHA SOMO LUMO (EV)    =" $filename | grep '='| awk '{printf "%12.6f \n",$7}')
BetaSOMO=$(grep "BETA  SOMO LUMO (EV)    =" $filename | grep '='| awk '{printf "%12.6f \n",$6}')
BetaLUMO=$(grep "BETA  SOMO LUMO (EV)    =" $filename | grep '='| awk '{printf "%12.6f \n",$7}')
HOMO=$(grep "HOMO LUMO ENERGIES (EV) =" $filename | grep '='| awk '{printf "%12.6f \n",$6}')
LUMO=$(grep "HOMO LUMO ENERGIES (EV) =" $filename | grep '='| awk '{printf "%12.6f \n",$7}')
CosmoArea=$(grep "COSMO AREA              =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')
CosmoVolume=$(grep "COSMO VOLUME            =" $filename | grep '='| awk '{printf "%12.6f \n",$4}')

var1=$(echo $TotalEnergy | cut -f1 -d' ')
var2=$(echo $TotalEnergy | cut -f2 -d' ')
TotalEkcal="$var1"
TotalEeV="$var2"

if [ "$DispE" = "" ];
then
   DispE="-----"
fi
if [ "$HBondE" = "" ];
then
   HBondE="-----"
fi
if [ "$NHBonds" = "" ];
then
   NHBonds="-----"
fi
if [ "$IonPot" = "" ];
then
   IonPot="-----"
fi
if [ "$AlphaSOMO" = "" ];
then
   AlphaSOMO="-----"
fi
if [ "$AlphaLUMO" = "" ];
then
   AlphaLUMO="-----"
fi
if [ "$BetaSOMO" = "" ];
then
   BetaSOMO="-----"
fi
if [ "$BetaLUMO" = "" ];
then
   BetaLUMO="-----"
fi
if [ "$HOMO" = "" ];
then
   HOMO="-----"
fi
if [ "$LUMO" = "" ];
then
   LUMO="-----"
fi


echo $filename, $HeatF, $TotalEkcal, $TotalEeV, $DispE, $HBondE, $NHBonds, $IonPot, $AlphaSOMO, $AlphaLUMO, $BetaSOMO, $BetaLUMO, $HOMO, $LUMO, $CosmoArea, $CosmoVolume >> $1.t379x24
done
echo 'Filename', 'Heat of formation (kcal/mol)', 'Total Energy (kcal/mol)', 'Total Energy (eV)', 'Dispersion Energy (eV)', 'H-BOND Ebergy (eV)', 'No. HBonds', 'Ionization Potential (eV)', 'AlphaSOMO (eV)', 'AlphaLUMO (eV)', 'BetaSOMO (eV)', 'BetaLUMO (eV)', 'HOMO (eV)', 'LUMO (eV)', 'COSMO AREA (square angstroms)', 'COSMO VOLUME (cubic angstroms)' >> t379x24
cat t379x24 $1.t379x24 > $1.csv
rm -f t379x24 $1.t379x24
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .