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

Refactor: move "hPsi-call-act" procedure from OperatorPW into basic Operator and redesign act() interface #2911

Closed
maki49 opened this issue Sep 7, 2023 · 2 comments · Fixed by #2912
Assignees

Comments

@maki49
Copy link
Collaborator

maki49 commented Sep 7, 2023

Background

Why move to basic class?

  • for physics: act() is a basic property of an operator to a vector: $\ket{\psi_\text{out}}=\hat{O}\ket{\psi_\text{in}}$
  • for demand:
    • LR-TDDFT Implementation #2460 has 2 different types of operators inheriting basic Operator rather than OperatorPW, whose act() interface will be called in hPsi() in sequence.
    • if a derived class (like OperatorLCAO) doesn't need the hPsi-call-act procedure, just ignore or override it.

Why redesign the interface?

The old act() inteface uses both psi::Psi<std::complex<FPTYPE>, Device> *psi_in and std::complex<FPTYPE>* tmpsi_in (the data pointer of psi_in) as input, which is a kind of redundancy.

What's changed (in #2912)

  • move "hPsi-call-act" procedure from OperatorPW into basic Operator
  • redesign act() interface:
    • hardware-friendly type:
    virtual void act(const int nbands,
          const int nbasis,
          const int npol,
          const FPTYPE* tmpsi_in,
          FPTYPE* tmhpsi,
          const int ngk_ik = 0)const;
    
    • developer-friendly type:
    virtual psi::Psi<FPTYPE> act(const psi::Psi<FPTYPE>& psi_in) const;
    
@maki49 maki49 changed the title Refactor: move "hPsi-call-act" procedure from OperatorPW into basic Operator and design act() interface Refactor: move "hPsi-call-act" procedure from OperatorPW into basic Operator and redesign act() interface Sep 7, 2023
@mohanchen
Copy link
Collaborator

I agree.

@hongriTianqi
Copy link

hongriTianqi commented Sep 8, 2023

  • Identify the specific code file or section with the code quality issue.
  • Investigate the issue and determine the root cause.
  • Research best practices and potential solutions for the identified issue.
  • Refactor the code to improve code quality, following the suggested solution.
  • Ensure the refactored code adheres to the project's coding standards.
  • Test the refactored code to ensure it functions as expected.
  • Update any relevant documentation, if necessary.
  • Submit a pull request with the refactored code and a description of the changes made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants