-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Orca Interface for Calculations via orca. (#12)
Start orca with an orca input file. Get a JSON file with properties. Read that file.
- Loading branch information
Showing
4 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// Created by gerd on 11.12.24. | ||
// | ||
|
||
#include "orcainterface.h" | ||
#include <iostream> | ||
#include <fstream> | ||
#include <cstdlib> | ||
#include <sstream> | ||
|
||
OrcaInterface::OrcaInterface() { | ||
inputFilePath = "orca.inp"; | ||
outputFilePath = "orca.out"; | ||
} | ||
|
||
OrcaInterface::~OrcaInterface() { | ||
// Optionale Bereinigungsoperationen | ||
} | ||
|
||
void OrcaInterface::setInputFile(const std::string& inputFile) { | ||
inputFilePath = inputFile; | ||
} | ||
|
||
bool OrcaInterface::createInputFile(const std::string& content) { | ||
std::ofstream outFile(inputFilePath); | ||
if (!outFile) { | ||
std::cerr << "Fehler beim Erstellen der Eingabedatei!" << std::endl; | ||
return false; | ||
} | ||
outFile << content; | ||
outFile.close(); | ||
return true; | ||
} | ||
|
||
bool OrcaInterface::executeOrcaProcess() { | ||
// Hier rufen wir das ORCA-Programm über einen Systemaufruf auf | ||
std::stringstream command; | ||
command << "orca " << inputFilePath << " > " << outputFilePath; | ||
int result = std::system(command.str().c_str()); | ||
|
||
// Überprüfen, ob der ORCA-Prozess erfolgreich ausgeführt wurde | ||
return (result == 0); | ||
} | ||
|
||
bool OrcaInterface::runOrca() { | ||
// Starten Sie den ORCA-Prozess und warten Sie auf das Ergebnis | ||
std::cout << "Starte ORCA..." << std::endl; | ||
if (executeOrcaProcess()) { | ||
std::cout << "ORCA abgeschlossen!" << std::endl; | ||
return true; | ||
} else { | ||
std::cerr << "Fehler beim Ausführen von ORCA!" << std::endl; | ||
return false; | ||
} | ||
} | ||
|
||
void OrcaInterface::readOrcaJSON() { | ||
// Liest die Ergebnisse aus der ORCA-Ausgabedatei | ||
std::ifstream property(inputFilePath+".property.json"); | ||
property >> OrcaJSON; | ||
} | ||
|
||
bool OrcaInterface::getOrcaJSON() { | ||
// Hier rufen wir das ORCA_2JSON-Programm über einen Systemaufruf auf | ||
std::stringstream command; | ||
command << "orca_2json " << inputFilePath << " -property >> " << outputFilePath; | ||
const int result = std::system(command.str().c_str()); | ||
|
||
// Überprüfen, ob der ORCA-Prozess erfolgreich ausgeführt wurde | ||
return (result == 0); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Created by gerd on 11.12.24. | ||
// | ||
|
||
#pragma once | ||
#ifndef ORCAINTERFACE_H | ||
#define ORCAINTERFACE_H | ||
|
||
#include "src/core/molecule.h" | ||
|
||
static json ORCASettings{ | ||
{ "tb_acc", 1 }, | ||
{ "tb_max_iter", 250 }, | ||
{ "tb_damping", 0.4 }, | ||
{ "tb_temp", 9.500e-4 }, | ||
{ "tb_verbose", 0 }, | ||
{ "tb_guess", "SAD" }, | ||
{ "cpcm_solv", "none" }, | ||
{ "alpb_solv", "none" }, | ||
{ "cpcm_eps", -1 }, | ||
{ "alpb_eps", -1 } | ||
}; | ||
|
||
class OrcaInterface { | ||
public: | ||
explicit OrcaInterface(); | ||
~OrcaInterface(); | ||
|
||
// Setzt die ORCA Eingabedaten | ||
void setInputFile(const std::string& inputFile); | ||
|
||
// Führt ORCA aus und wartet auf die Beendigung | ||
bool runOrca(); | ||
|
||
// Liest die Ergebnisse aus der ORCA-Ausgabedatei | ||
void readOrcaJSON(); | ||
|
||
// Create Output.JSON | ||
bool getOrcaJSON(); | ||
|
||
private: | ||
std::string inputFilePath; | ||
std::string outputFilePath; | ||
json OrcaJSON; | ||
|
||
// Hilfsfunktionen | ||
bool createInputFile(const std::string& content); | ||
bool executeOrcaProcess(); | ||
}; | ||
|
||
#endif //ORCAINTERFACE_H |
This file contains 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