From 3bd22c23d34d7fc605d86dcbd92873fac00c9cff Mon Sep 17 00:00:00 2001 From: Adrian Hurtado Date: Mon, 18 Sep 2023 11:23:47 -0400 Subject: [PATCH] place all vtk density plots in a single file --- src/apps/molresponse/Plot_VTK.cc | 32 +++++++++++++++++++++++++++ src/apps/molresponse/Plot_VTK.h | 3 +++ src/apps/molresponse/ResponseBase.cpp | 4 ++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/apps/molresponse/Plot_VTK.cc b/src/apps/molresponse/Plot_VTK.cc index 9a909782f6a..0818ab255d2 100644 --- a/src/apps/molresponse/Plot_VTK.cc +++ b/src/apps/molresponse/Plot_VTK.cc @@ -157,6 +157,38 @@ namespace madness { state_number++; }); } + void do_response_density_vtk_plots_new(World &world, int npt_plot, double L, const Molecule &molecule, + const real_function_3d &ground_density, + const vector_real_function_3d &response_density) { + // Stuff needed to plot + // + Vector box_lo{-L / 4, -L / 4, -L / 4}; + Vector box_hi{L / 4, L / 4, L / 4}; + + + std::string vtk_dir = "vtk_plots"; + std::filesystem::create_directories(vtk_dir); + + std::string geo_file; + const char *filename; + + Vector points{npt_plot, npt_plot, npt_plot}; + + std::string response_file; + //***********************************ground density plot + auto density_file = vtk_dir + "/" + "density.vts"; + filename = density_file.c_str(); + plotvtk_begin<3>(world, filename, box_lo, box_hi, points, true); + plotvtk_data(ground_density, "ground", world, filename, box_lo, box_hi, points, true, false); + //***********************************ground density plot + int state_number = 0; + std::for_each(response_density.begin(), response_density.end(), [&](const auto &rho_i) { + auto field_name = "response_" + std::to_string(state_number); + plotvtk_data(rho_i, field_name.c_str(), world, filename, box_lo, box_hi, points, true, false); + state_number++; + }); + plotvtk_end<3>(world, filename, true); + } void do_vtk_plots(World &world, int npt_plot, double L, int lowest_orbital, int highest_orbital, const Molecule &molecule, std::vector densities, const std::string &name) { // Stuff needed to plot diff --git a/src/apps/molresponse/Plot_VTK.h b/src/apps/molresponse/Plot_VTK.h index 81fd50824a2..f9b1458e2c6 100644 --- a/src/apps/molresponse/Plot_VTK.h +++ b/src/apps/molresponse/Plot_VTK.h @@ -46,6 +46,9 @@ namespace madness { const real_function_3d &ground_density, const vector_real_function_3d &response_density); + void do_response_density_vtk_plots_new(World &world, int npt_plot, double L, const Molecule &molecule, + const real_function_3d &ground_density, + const vector_real_function_3d &response_density); void do_vtk_plots(World &world, int npt_plot, double L, int lowest_orbital, int highest_orbital, const Molecule &molecule, std::vector densities, const std::string &name); diff --git a/src/apps/molresponse/ResponseBase.cpp b/src/apps/molresponse/ResponseBase.cpp index b07a16d5cd1..cd6ee7cae29 100644 --- a/src/apps/molresponse/ResponseBase.cpp +++ b/src/apps/molresponse/ResponseBase.cpp @@ -1348,8 +1348,8 @@ void ResponseBase::solve(World &world) { auto r_matrix = to_response_matrix(Chi); auto response_densities = make_density(world, Chi); do_response_orbital_vtk_plots(world, r_params.plot_pts(), r_params.L(), molecule, ground_orbitals, r_matrix); - do_response_density_vtk_plots(world, r_params.plot_pts(), r_params.L(), molecule, ground_density, - response_densities); + do_response_density_vtk_plots_new(world, r_params.plot_pts(), r_params.L(), molecule, ground_density, + response_densities); } #endif #endif