Skip to content

Commit

Permalink
Run from input
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Jul 1, 2024
1 parent 22ba65a commit 1fb0ef9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 24 deletions.
38 changes: 19 additions & 19 deletions src/apps/molresponse/response_coordinator2/coordinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ class ParameterManager {
ResponseParameters molresponse_params;

public:
ParameterManager() = default;

void print_params() 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("-------------------------------------------");
}
explicit ParameterManager(World &world, commandlineparser par):parser(std::move(par)) {
molecule = Molecule(world, this->parser);
moldft_params = CalculationParameters(world, this->parser);
molresponse_params = ResponseParameters(world, this->parser);
all_input_json = {};
all_input_json["dft"] = moldft_params.to_json_if_precedence("defined");
all_input_json["response"] = molresponse_params.to_json_if_precedence("defined");
all_input_json["molecule"] = molecule.to_json();
write_json_input();
}

explicit ParameterManager(World &world, const path &file_path) {

Expand Down Expand Up @@ -244,25 +263,6 @@ class ParameterManager {



}

explicit ParameterManager(World
&world, commandlineparser
parser) : parser(std::move(parser)) {

molecule = Molecule(world, this->parser);
moldft_params = CalculationParameters(world, this->parser);

molresponse_params = ResponseParameters(world, this->parser);


all_input_json = {};
all_input_json["dft"] = moldft_params.to_json_if_precedence("defined");
all_input_json["response"] = molresponse_params.to_json_if_precedence("defined");
all_input_json["molecule"] = molecule.to_json();

write_json_input();

}

json get_input_json() {
Expand Down
32 changes: 28 additions & 4 deletions src/apps/molresponse/response_coordinator2/mad-freq2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//
// 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)

Expand All @@ -20,6 +22,7 @@ using path = std::filesystem::path;
using namespace madness;



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

madness::initialize(argc, argv);
Expand All @@ -28,14 +31,35 @@ auto main(int argc, char *argv[]) -> int {
{
World world(SafeMPI::COMM_WORLD);
startup(world, argc, argv, true);
if (world.rank() == 0) print(info::print_revision_information());

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();

path input_json("resources/inputs/freq_input.json");
path mol_input("resources/molecules/H2.mol");

ParameterManager params(world, input_json, mol_input);
auto response_manager = ResponseCalcManager(world, params);

if(world.rank() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ TEST_CASE("Define parameters with input and mol file separately") {

ParameterManager params(world, input_json, mol_input);
auto response_manager = ResponseCalcManager(world, params);

response_manager.run_moldft(world,false);
}

Expand Down

0 comments on commit 1fb0ef9

Please sign in to comment.