Skip to content

Commit

Permalink
truncating the update, hopefully reducing noisy solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ahurta92 committed Oct 26, 2023
1 parent 79d8fb2 commit fe7c328
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
14 changes: 0 additions & 14 deletions src/apps/molresponse/FrequencyResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,6 @@ auto FrequencyResponse::update_response(World &world, X_space &chi, XCOperator<d
if (iteration >= 0) {// & (iteration % 3 == 0)) {
new_chi = kain_x_space_update(world, chi, new_res, kain_x_space);
}
// here only accept the kain updates if residual_norm is bigger than max_rotaion
/*
for (const auto &b: chi.active) {
if (bsh_norms[b] > max_rotation) {
new_chi.x[b] = kain_chi.x[b];
if (r_params.calc_type() == "full") { new_chi.y[b] = kain_chi.y[b]; }
} else {
if (world.rank() == 0)
print("not accepting kain update since residual norm:", bsh_norms[b],
" is smaller than max rotation: ", max_rotation);
}
}
*/


inner_to_json(world, "x_update", response_context.inner(new_chi, new_chi), iter_function_data);

Expand Down
9 changes: 7 additions & 2 deletions src/apps/molresponse/ResponseBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,12 +1195,16 @@ auto ResponseBase::kain_x_space_update(World &world, const X_space &chi, const X

for (const auto &i: Chi.active) {
auto temp = kain_x_space[i].update(x_vectors[i], x_residuals[i]);
truncate(world, temp);
std::copy(temp.begin(), temp.begin() + n, kain_update.x[i].begin());
std::copy(temp.begin() + n, temp.end(), kain_update.y[i].begin());
};
} else {
// first compute the residuals
for (const auto &i: Chi.active) { kain_update.x[i] = kain_x_space[i].update(chi.x[i], residual_chi.x[i]); }
for (const auto &i: Chi.active) { kain_update.x[i] = kain_x_space[i].update(chi.x[i], residual_chi.x[i]);
// truncate the update
truncate(world, kain_update.x[i]);
}
}
if (r_params.print_level() >= 1) { molresponse::end_timer(world, "kain_x_update", "kain_x_update", iter_timing); }
return kain_update;
Expand All @@ -1222,7 +1226,8 @@ void ResponseBase::x_space_step_restriction(World &world, const X_space &old_Chi
auto m_new = to_response_matrix(temp);
auto m_diff = to_response_matrix(diff);

for (size_t b = 0; b < m; b++) {
// only restrict active states
for (const auto &b: old_Chi.active) {
auto step_size = norm2(world, m_diff[b]);
auto norm_xb = norm2(world, m_old[b]);
auto max_step = max_bsh_rotation;//norm;//* norm_xb;
Expand Down

0 comments on commit fe7c328

Please sign in to comment.