Skip to content

Commit

Permalink
okay now i fixed it I think
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Dec 14, 2023
1 parent 9ee8c9f commit 74fe8be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/apps/molresponse/FrequencyResponse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class QuadraticResponse : public ResponseBase {
std::make_unique<FullDensityStrategy>(), std::make_unique<LoadFrequencyXSpace>());
}

x_data[i] = frequency_contexts[i].load_x_space(world, restart_files[i], r_params);
x_data[i] = frequency_contexts[i].load_x_space(world, restart_files[i], r_params, omega);
::check_k(world, x_data[i].first, FunctionDefaults<3>::get_thresh(), r_params.k());
}
};
Expand Down
25 changes: 17 additions & 8 deletions src/apps/molresponse/ResponseBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ typedef std::pair<vector_real_function_3d, vector_real_function_3d> double_respo
class LoadXSpaceStrategy {
public:
virtual ~LoadXSpaceStrategy() = default;
virtual XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params) const = 0;
virtual XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params,
double omega_state) const = 0;
};
class LoadFrequencyXSpace : public LoadXSpaceStrategy {
public:
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params) const override {
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params,
double omega_state) const override {
if (world.rank() == 0) {
print("FrequencyResponse::load() -state");
print("Loading X_space from file: ", filename);
print("Number of states: ", r_params.num_states());
print("Number of orbitals: ", r_params.num_orbitals());
print("Loading omega : ", r_params.omega());
print("Loading omega : ", omega_state);
}
//

Expand All @@ -61,16 +63,22 @@ class LoadFrequencyXSpace : public LoadXSpaceStrategy {
for (size_t i = 0; i < r_params.num_states(); i++)
for (size_t j = 0; j < r_params.num_orbitals(); j++) ar & chi_new.x[i][j];
world.gop.fence();
for (size_t i = 0; i < r_params.num_states(); i++)
for (size_t j = 0; j < r_params.num_orbitals(); j++) ar & chi_new.y[i][j];
if (omega_state == 0.0) {
for (size_t i = 0; i < r_params.num_states(); i++)
for (size_t j = 0; j < r_params.num_orbitals(); j++) chi_new.y[i][j] = chi_new.x[i][j];
} else {
for (size_t i = 0; i < r_params.num_states(); i++)
for (size_t j = 0; j < r_params.num_orbitals(); j++) ar & chi_new.y[i][j];
}
world.gop.fence();

return {chi_new, Tensor<double>()};
}
};
class LoadExcitedXSpace : public LoadXSpaceStrategy {
public:
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params) const override {
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params,
double omega_state) const override {

Tensor<double> omega;
auto new_chi = X_space(world, r_params.num_states(), r_params.num_orbitals());
Expand Down Expand Up @@ -420,9 +428,10 @@ class Context {
"inner", "ResponseBase.hpp");
}
}
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params) const {
XData load_x_space(World &world, const std::string &filename, const ResponseParameters &r_params,
double omega_state) const {
if (load_x_space_strategy_) {
return load_x_space_strategy_->load_x_space(world, filename, r_params);
return load_x_space_strategy_->load_x_space(world, filename, r_params, 0);
} else {
throw madness::MadnessException("Load X Space Strategy isn't set", "Need to set a strategy", 2, 455,
"inner", "ResponseBase.hpp");
Expand Down

0 comments on commit 74fe8be

Please sign in to comment.