Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excitation energies #395

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions doc/users/user_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,42 @@ User input reference

**Default** ``initial_guess/phi_b``

:guess_cube_x_p: File name for paired orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/x_p_rsp_idx_<0...Np>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/X_p``

:guess_cube_x_a: File name for alpha orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/x_a>_rsp_idx_<0...Na>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/X_a``

:guess_cube_x_b: File name for beta orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/x_b_rsp_idx_<0...Nb>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/X_b``

:guess_cube_y_p: File name for paired orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/y_p_rsp_idx_<0...Np>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/Y_p``

:guess_cube_y_a: File name for alpha orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/y_a>_rsp_idx_<0...Na>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/Y_a``

:guess_cube_y_b: File name for beta orbitals, used with ``cube`` guess. Expected path is ``<path_orbitals>/y_b_rsp_idx_<0...Nb>_<re/im>.cube

**Type** ``str``

**Default** ``initial_guess/Y_b``

:cube_vectors: Directory where cube vectors are stored for mrchem calculation.

**Type** ``str``
Expand Down
66 changes: 65 additions & 1 deletion pilot/mrchem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@

#include <MRCPP/Printer>
#include <MRCPP/Timer>
#include <fstream>
#include <string>

#include "analyticfunctions/CUBEfunction.h"
#include "mrchem.h"
#include "mrenv.h"
#include "parallel.h"

#include "qmfunctions/Orbital.h"
#include "qmfunctions/orbital_utils.h"
// Initializing global variables
mrcpp::MultiResolutionAnalysis<3> *mrchem::MRA;

using json = nlohmann::json;
using Timer = mrcpp::Timer;
using namespace mrchem;

std::shared_ptr<mrchem::CUBEfunction> getCUBEFunction(const json &json_cube, int i);
int main(int argc, char **argv) {
mpi::initialize();
const auto json_inp = mrenv::fetch_json(argc, argv);
Expand All @@ -47,6 +52,50 @@ int main(int argc, char **argv) {
Timer timer;

// Do your stuff here

auto prec = 1.0e-3;

std::string mo_file = "pilot_vec_p.cube";
json cube_inp;
std::ifstream ifs(mo_file, std::ios_base::in);
ifs >> cube_inp;
ifs.close();
Orbital phi(1.0);
phi.alloc(NUMBER::Real);
for (int i = 0; i < 10; i++) {
auto phi_i = getCUBEFunction(cube_inp, i % 5);
mrcpp::project(prec, phi.real(), *phi_i);
std::cout << "first norm of phi at cycle " << i << ": " << phi.norm() << "\n";
phi.free(NUMBER::Real);

phi.alloc(NUMBER::Real);
mrcpp::project(prec, phi.real(), *phi_i);
std::cout << "first norm of phi at cycle " << i << ": " << phi.norm() << "\n";
phi.free(NUMBER::Real);

phi.alloc(NUMBER::Real);
mrcpp::project(prec, phi.real(), *phi_i);
std::cout << "first norm of phi at cycle " << i << ": " << phi.norm() << "\n";
phi.free(NUMBER::Real);

phi.alloc(NUMBER::Real);
mrcpp::project(prec, phi.real(), *phi_i);
std::cout << "first norm of phi at cycle " << i << ": " << phi.norm() << "\n";

OrbitalVector orb_vec;

for (auto j = 0; j < 5; j++) {
Orbital psi(1.0);
psi.alloc(NUMBER::Real);
auto psi_j = getCUBEFunction(cube_inp, j % 5);
mrcpp::project(prec, psi.real(), *psi_j);
std::cout << "first norm of psi at cycle " << i << " and " << j << ": " << psi.norm() << "\n";
orb_vec.push_back(psi);
}
std::cout << "norms of the orbitalvector: " << orbital::get_norms(orb_vec) << "\n";
}
// Did my stuff there

println(0, json_inp.dump(2));

timer.stop();
Expand All @@ -56,3 +105,18 @@ int main(int argc, char **argv) {
mpi::finalize();
return EXIT_SUCCESS;
}

std::shared_ptr<mrchem::CUBEfunction> getCUBEFunction(const json &json_cube, int index) {
auto Header = json_cube[index]["Header"];
auto N_atoms = Header["N_atoms"];
auto origin = Header["origin"];
auto N_steps = Header["N_steps"];
auto Voxel_axes = Header["Voxel_axes"];
auto Z_n = Header["Z_n"];
auto atom_charges = Header["atom_charges"];
auto atom_coords = Header["atom_coords"];
auto N_vals = Header["N_vals"];
auto CUBE_data = json_cube[index]["CUBE_data"][0];

return std::make_shared<CUBEfunction>(N_atoms, N_vals, N_steps, origin, Voxel_axes, Z_n, CUBE_data, atom_charges, atom_coords);
}
27 changes: 19 additions & 8 deletions pilot/mrchem.inp
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# vim:syntax=sh:

rel_prec = 1.0e-5 # Overall relative precision
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this file changed?

world_prec = 1.0e-5 # Overall relative precision

Printer {
print_level = 0
print_prec = 6
print_width = 70
print_mpi = false
print_input = false
}

MRA {
order = 7 # Polynomial order
min_scale = -3 # Root scale defines world size 2^{-scale}
max_scale = 20 # Maximum refinement
corner = [-1, -1, -1 ] # Translation of corner root box [x,y,z]
boxes = [ 2, 2, 2 ] # Number of root boxes [x,y,z]
WaveFunction {
method = HF # Wave function method (HF or DFT)
restricted = true
}

Molecule {
$coords
O 0.000000000000 0.000000000000 0.000000000000
H 0.000000000000 0.740848095288 0.582094932012
H 0.000000000000 -0.740848095288 0.582094932012
$end
}

MPI {
numerically_exact = true
}

Basis {
type = interpolating
}
Loading