Created
February 1, 2017 12:14
-
-
Save andersx/92550e6b8e1362ed0cf4327666feca54 to your computer and use it in GitHub Desktop.
Example to run mopac and get energy via C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double calc_mopac_energy(OpenBabel::OBMol &mol) { | |
| OpenBabel::OBConversion conv; | |
| conv.SetInAndOutFormats("moo", "mop"); | |
| std::remove("temp.mop"); | |
| std::remove("temp.out"); | |
| std::remove("temp.arc"); | |
| std::ofstream ofs("temp.mop"); | |
| conv.Write(&mol, &ofs); | |
| system("./run_mopac"); | |
| ofs.close(); | |
| std::ifstream ifs; | |
| OpenBabel::OBMol molout; | |
| ifs.open("temp.out"); | |
| conv.Read(&molout, &ifs); | |
| ifs.close(); | |
| return molout.GetEnergy(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment