pvector get_grad_and_E(double& E,const pvector& u,const pvector& Vtilde);Return value:
- pvector which contains the gradient of the energy function
Output:
- E: value of the energy function.
Input:
- u: expansion coefficients of non-normalized wave function
- Vtilde: expansion coefficients of effective representation of the potential, so that the potential energy is POT=u^(Idag(Vtilde*I(u))).
To make the transition to the Kohn-Sham equations easier, it helps to isolate the algorithm (conjugate-gradients) from the physics (computation of E and grad). To do this, make a copy of your ``sch.C'' program called ``sch2.C'' and add a function of the above prototype to it.
Debugging: Write ``sch2.C'' so that it calls get_grad_and_E() to do all of the energy and gradient calculations, and verify that it produces exactly the same output as your original ``sch.C.''