Skip to content

Commit

Permalink
The start of the new executable
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Jul 1, 2024
1 parent 5b7a395 commit fb275a7
Show file tree
Hide file tree
Showing 3 changed files with 334 additions and 130 deletions.
7 changes: 7 additions & 0 deletions src/apps/molresponse/ResponseExceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ class Response_Convergence_Error : public MadException {
__LINE__, __FUNCTION__, __FILE__) {}
};

class Quad_Response_Error : public MadException {
public:
explicit Quad_Response_Error()
: MadException("Previous frequency response calculation did not converge ", nullptr, 25,
__LINE__, __FUNCTION__, __FILE__) {}
};

#endif// MADNESS_RESPONSEEXCEPTIONS_HPP
79 changes: 79 additions & 0 deletions src/apps/molresponse/testing/mad-quadratic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// Created by adrianhurtado on 1/1/22.
//
#include "ResponseExceptions.hpp"
#include "madness/tensor/tensor_json.hpp"
#include "madness/world/worldmem.h"
#include "response_functions.h"
#include "runners.hpp"

#if defined(HAVE_SYS_TYPES_H) && defined(HAVE_SYS_STAT_H) && defined(HAVE_UNISTD_H)

#include <sys/stat.h>
#include <unistd.h>

static inline int file_exists(const char *input_name) {
struct stat buffer {};
size_t rc = stat(input_name, &buffer);
return (rc == 0);
}

#endif

using path = std::filesystem::path;

using namespace madness;


auto main(int argc, char *argv[]) -> int {

madness::initialize(argc, argv);

{
World world(SafeMPI::COMM_WORLD);
startup(world, argc, argv, true);

try {
sleep(5);
std::cout.precision(6);
if (argc != 5) {
std::cout << "Wrong number of inputs" << std::endl;
return 1;
}
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]};


auto schema = runSchema(world, xc);
auto m_schema = moldftSchema(world, molecule_name, xc, schema);
auto f_schema = frequencySchema(world, schema, m_schema, op);


runQuadraticResponse(world, f_schema, precision);
world.gop.fence();
} catch (const SafeMPI::Exception &e) {
print(e.what());
error("caught an MPI exception");
} catch (const madness::MadnessException &e) {
print(e);
error("caught a MADNESS exception");
} catch (const madness::TensorException &e) {
print(e.what());
error("caught a Tensor exception");
} catch (const nlohmann::detail::exception &e) {
print(e.what());
error("Caught JSON exception");
} catch (const std::filesystem::filesystem_error &ex) {
std::cerr << ex.what() << "\n";
} catch (const std::exception &e) {
print(e.what());
error("caught an STL exception");
} catch (...) { error("caught unhandled exception"); }
// Nearly all memory will be freed at this point
print_stats(world);
}
finalize();
return 0;
}
Loading

0 comments on commit fb275a7

Please sign in to comment.