Skip to content

Commit

Permalink
rename to mad-dft
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Jul 1, 2024
1 parent a72457d commit a22d89d
Show file tree
Hide file tree
Showing 104 changed files with 156 additions and 120 deletions.
2 changes: 1 addition & 1 deletion src/apps/molresponse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if(CMAKE_CXX_STANDARD GREATER_EQUAL 17)
# C++ standard is 17 or higher
add_subdirectory(response_coordinator)
add_subdirectory(response_coordinator2)
add_subdirectory(maddft)
# Add your code or configurations here
else()
# C++ standard is below 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


set(MY_EXECUTABLES
mad-freq2
mad-dft
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,35 @@ class ParameterManager {
public:
ParameterManager() = default;

void print_params() const {
void print_file_paths() const {
::print("------------Parameter Manager---------------");
::print("Input File Path: ", input_file_path);
::print("Input File Json Path: ", input_file_json_path);
::print("Input File Base: ", input_file_base);
::print("-------------------------------------------");



}

static void help() {
print_header2("help page for MADNESS DFT and Response Properties Code ");
print("This code is designed to run DFT and Response Property calculations");
print("Within the input one defines both the ground and response calculations in the input file by specifiying the dft and response blocks");
print("By defining the quadratic block one can compute quadratic response properties such as the hyperpolarizability");

}
void print_params() const {
::print("------------Parameter Manager---------------");
::print("Molecule: ");
molecule.print();
::print("Moldft Parameters: ");
moldft_params.print();
::print("Molresponse Parameters: ");
molresponse_params.print();
::print("-------------------------------------------");


}
explicit ParameterManager(World &world, commandlineparser par):parser(std::move(par)) {
molecule = Molecule(world, this->parser);
Expand Down
130 changes: 130 additions & 0 deletions src/apps/molresponse/maddft/mad-dft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//
// Created by adrianhurtado on 1/1/22.
#include "FrequencyResponse.hpp"
#include "coordinator.hpp"
#include <madness/misc/info.h>

#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);
std::cout.precision(6);

{
World world(SafeMPI::COMM_WORLD);
ParameterManager params;
if (world.rank() == 0) {
print_header1("MOLDFT -- molecular DFT and Hartree-Fock code with TDHF and TDDFT");
}
startup(world, argc, argv, true);
if (world.rank() == 0) print(info::print_revision_information());
commandlineparser parser(argc, argv);

if (parser.key_exists("help")) {
SCF::help();

} else if (parser.key_exists("print_parameters")) {
params.print_params();
} else {


try {
// I need to write a help and a print parameters function which will be called by the commandlineparser
print_meminfo(world.rank(), "startup");

ParameterManager params;
if (argc == 1) {
print("No input file found");
path input_json("resources/inputs/freq_input.json");
path mol_input("resources/molecules/H2O.mol");
params = ParameterManager(world, input_json, mol_input);
} else if (argc == 2) {
print("Input file found");
path input_file(argv[1]);
commandlineparser parser(argc, argv);
params = ParameterManager(world, parser);
} else if (argc == 3) {
print("Input and mol file found");
path input_file(argv[1]);
path mol_input(argv[2]);
params = ParameterManager(world, input_file, mol_input);
} else {
error("Too many arguments");
}

//print params
params.print_params();

auto response_manager = ResponseCalcManager(world, params);

if (world.rank() == 0) {
print("Running MOLDFT");
print("Calc Info Path: ", response_manager.calc_info_json_path);
print("Moldft Path: ", response_manager.moldft_path);
}

if (std::filesystem::exists(response_manager.calc_info_json_path) &&
std::filesystem::exists(response_manager.moldft_path)) {
response_manager.run_molresponse(world);
} else {
if (world.rank() == 0) {
print("Running MOLDFT since no previous calculation was found");
}
response_manager.run_moldft(world, true);
world.gop.fence();
response_manager.run_molresponse(world);
world.gop.fence();
}

// if quadratic response is requested
//
if (params.get_molresponse_params().quadratic()) {
if (world.rank() == 0) {
print("Compute Quadratic Response Properties ");
}
response_manager.run_quadratic_response(world);
}

} 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);
if (world.rank() == 0) { print("Finished All Frequencies"); }
}
}
finalize();
return 0;
}
117 changes: 0 additions & 117 deletions src/apps/molresponse/response_coordinator2/mad-freq2.cpp

This file was deleted.

0 comments on commit a22d89d

Please sign in to comment.