Skip to content

Commit

Permalink
adding ortho algorithm initial movecs opptimize to avoid lagrange nan…
Browse files Browse the repository at this point in the history
…...EJB
  • Loading branch information
ebylaska committed Oct 11, 2024
1 parent 65ef3b2 commit 71628bb
Show file tree
Hide file tree
Showing 5 changed files with 531 additions and 4 deletions.
42 changes: 42 additions & 0 deletions Nwpw/nwpwlib/D3dB/Pneb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,48 @@ void Pneb::g_project_out_filled(double *psi, const int ms, double *Horb)
}
}

/**************************************
* *
* Pneb::g_project_out_filled_below *
* *
**************************************/
/**
* @brief Projects out components below a certain index in the provided psi array.
*
* This function modifies the Horb array by removing contributions from components
* of the psi array that are indexed below the specified value of `k`. It loops over
* the elements of `psi` from `k-1` down to `0`, computes the dot product of the
* relevant part of `psi` and `Horb`, and applies a scaled update to `Horb` using
* daxpy operations.
*
* @param psi Pointer to an array of doubles, representing the wave function or state vector.
* @param ms Integer index, representing a state or iteration.
* @param k Integer index, specifying the cutoff for the projection.
* @param Horb Pointer to an array of doubles, representing orbital data or coefficients to be updated.
*
* @details
* The function utilizes the PGrid class's `npack`, `cc_pack_dot`, and `cc_pack_daxpy`
* methods to perform packed dot product and daxpy operations efficiently.
*
* The `psi` array is accessed via the computed `indx` values, which incorporate
* both the loop index `km` and the `ms` shift.
*
* @note
* This function assumes that the PGrid class provides methods for handling packed
* grid data and that `ne[0]` is globally accessible within this class or namespace.
*/
void Pneb::g_project_out_filled_below(double *psi, const int ms, const int k, double *Horb)
{
int ishift = ms*ne[0]*2*PGrid::npack(1);
for (auto km=k-1; km>=0; --km)
{
int indx = 2*PGrid::npack(1)*km + ishift;
double w = -PGrid::cc_pack_dot(1,psi+indx,Horb);
PGrid::cc_pack_daxpy(1,w,psi+indx,Horb);
}
}


/*********************************
* *
* Pneb::g_project_out_virtual *
Expand Down
1 change: 1 addition & 0 deletions Nwpw/nwpwlib/D3dB/Pneb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class Pneb : public PGrid, public d1db {
void g_ortho_excited(double *, const int *, double *);
void g_project_out_filled(double *, const int, double *);
void g_project_out_virtual(const int, const int *, const int, double *, double *);
void g_project_out_filled_below(double *, const int, const int, double *);

void g_norm(double *);

Expand Down
Loading

0 comments on commit 71628bb

Please sign in to comment.