Skip to content

Commit

Permalink
Moving files around
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Jul 1, 2024
1 parent eaccee5 commit 431a0bd
Show file tree
Hide file tree
Showing 97 changed files with 145 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/apps/molresponse/response_coordinator2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ foreach (EXECUTABLE ${RESPONSE_TEST_SOURCES})
target_compile_features(${EXECUTABLE} PRIVATE cxx_std_17)
endforeach ()

# Copy the test resources found in resources directory
file(COPY ${CMAKE_SRC_DIR}resources DESTINATION ${CMAKE_BINARY_DIR}/src/apps/molresponse/response_coordinator2)




Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"moldft": {
"dft__k": 7,
"dft__aobasis": "sto-3g",
"dft__econv": 1.0000e-05,
"dft__kain": true
},
"molresponse": {
"response__first_order": true,
"response__kain": true,
"response__dipole": true,
"response__maxsub": 10,
"response__maxiter": 10,
"response__omega": 0.0
}
}
42 changes: 19 additions & 23 deletions src/apps/molresponse/response_coordinator2/test_coordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "response_functions.h"
#include "string"
#include "x_space.h"
#include <filesystem>


using path = std::filesystem::path;
Expand Down Expand Up @@ -40,36 +41,31 @@ TEST_CASE("Hash Generation Test") {
// step 1 is to read molecule from molecule file or
// to read in the molecule directory from geometry input
Molecule molecule = Molecule();
molecule.read(world, "molecule.in");
path json_input_path("resources/inputs/input.json");
print("Full path to json input file: ", json_input_path.string());

std::string filename = "response.in";

commandlineparser parser(argc, argv);
path molecule_path("resources/molecules/Be.mol");
// print full path
print("Full path to molecule file: ", molecule_path.string());

if (parser.key_exists("help")) {
FrequencyResponse::help();
} else if (parser.key_exists("print_parameters")) {
FrequencyResponse::print_parameters();
} else {
molresponse::start_timer(world);

}


std::ifstream molecule_stream(molecule_path);

const std::string molecule_name{argv[1]};
const std::string xc{argv[2]};
const std::string op{argv[3]};
const std::string precision{argv[4]};
const std::string static_calc{argv[5]};
if (precision != "high" && precision != "low" && precision != "super") {
if (world.rank() == 0) { std::cout << "Set precision to low high super" << std::endl; }
return 1;
if (!molecule_stream.is_open()) {
throw std::runtime_error("Could not open molecule file");
} else {
molecule.read(molecule_stream);
molecule_stream.close();
}
auto schema = runSchema(world, xc);

// read in

print("Molecule read from file: ");
molecule.print();
// Read in json

std::ifstream input_stream(json_input_path);
json input_json = json::parse(input_stream);
print("Input json read from file: ");
print(input_json.dump(4));
}

105 changes: 105 additions & 0 deletions src/apps/molresponse/response_coordinator2/write_test_input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//
// Created by Florian Bischoff on 5/27/21.
// Modified by Adrian Hurtado on 2/01/22
//

#ifndef MADNESS_WRITE_RESPONSE_INPUT_H
#define MADNESS_WRITE_RESPONSE_INPUT_H

#include <madness/chem/CalculationParameters.h>

#include "response_parameters.h"

namespace molresponse {

/// will write a test input and remove it from disk upon destruction
struct write_test_input {

double eprec = 1.e-4;// was 1e-4 ... trying to make test faster

std::string filename_;
std::string molecule_path;
bool keepfile = true;

write_test_input() : filename_("moldft.in") {}

explicit write_test_input(const CalculationParameters &param, const std::string &filename, std::string mol_path)
: filename_(filename), molecule_path(mol_path) {
std::ofstream of(filename_);
write_to_test_input("dft", &param, of);
write_molecule_to_test_input(molecule_path, of);
of.close();
}

~write_test_input() {
if (not keepfile) std::remove(filename_.c_str());
}

std::string filename() const { return filename_; }

static std::ostream &write_to_test_input(const std::string &groupname, const QCCalculationParametersBase *param,
std::ostream &of) {
of << groupname << endl;
of << param->print_to_string(true);
of << "end\n";
return of;
}

static std::ostream &write_molecule_to_test_input(std::string mol_path, std::ostream &of) {


std::cout << mol_path << "\n";
std::ifstream mol_file(mol_path);
std::string line;
std::string no_orient_line;
int i = 0;
while (getline(mol_file, line)) {
if (i == 1) {
no_orient_line = "no_orient true";
std::cout << no_orient_line << "\n";
of << no_orient_line << "\n";
}
std::cout << line << "\n";
of << line << "\n";
i++;
}
return of;
}
};
/// will write a test input and remove it from disk upon destruction
struct write_response_input {

double eprec = 1.e-4;// was 1e-4 ... trying to make test faster

std::string filename_;
bool keepfile = true;

write_response_input() : filename_("response_test") {}

explicit write_response_input(const ResponseParameters &param, const std::string &filename)
: filename_(filename) {
std::ofstream of(filename_);
write_to_test_input("response", &param, of);
of.close();
}

~write_response_input() {
if (not keepfile) std::remove(filename_.c_str());
}

std::string filename() const { return filename_; }

static std::ostream &write_to_test_input(const std::string &groupname, const ResponseParameters *param,
std::ostream &of) {
of << groupname << endl;
of << param->print_to_string(true);
of << "end\n";
return of;
}
};


}// namespace molresponse


#endif//MADNESS_WRITE_RESPONSE_INPUT_H

0 comments on commit 431a0bd

Please sign in to comment.