forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 145
[Feature] TD-OFDFT #6538
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
Merged
Merged
[Feature] TD-OFDFT #6538
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ccb8a5d
add esolver_of_tddft
lyb9812 96dd8cc
esolver_of_tddft cmakelist
lyb9812 c87639c
move memeber function of esolver_of_tddft to module_ofdft
lyb9812 d311eb3
fix bug (confuse evolve_psi with evolve_phi)
lyb9812 262c4e5
change evolve_phi with evolve_ofdft; change to vector
lyb9812 020cd9d
Merge branch 'develop' into develop
lyb9812 c577829
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 70a0204
Merge branch 'develop' of https://github.com/lyb9812/abacus-develop i…
lyb9812 e65e75b
Merge branch 'develop' into develop
sunliang98 5acb224
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 d38224d
details
lyb9812 a252d05
Merge branch 'develop' of https://github.com/lyb9812/abacus-develop i…
lyb9812 cde47d3
code optimization
lyb9812 ea55c5c
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 a35a7ae
add situation of reading charge file for tdofdft
lyb9812 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #include "esolver_of_tddft.h" | ||
|
|
||
| #include "source_io/module_parameter/parameter.h" | ||
| #include "source_io/cube_io.h" | ||
| #include "source_io/output_log.h" | ||
| #include "source_io/write_elecstat_pot.h" | ||
| //-----------temporary------------------------- | ||
| #include "source_base/global_function.h" | ||
| #include "source_estate/module_charge/symmetry_rho.h" | ||
| #include "source_hamilt/module_ewald/H_Ewald_pw.h" | ||
| #include "source_pw/module_pwdft/global.h" | ||
| #include "source_io/print_info.h" | ||
| #include "source_estate/cal_ux.h" | ||
| //-----force------------------- | ||
| #include "source_pw/module_pwdft/forces.h" | ||
| //-----stress------------------ | ||
| #include "source_pw/module_ofdft/of_stress_pw.h" | ||
|
|
||
| namespace ModuleESolver | ||
| { | ||
|
|
||
| ESolver_OF_TDDFT::ESolver_OF_TDDFT() | ||
| { | ||
| this->classname = "ESolver_OF_TDDFT"; | ||
| this->evolve_phi=new EVOLVE_PHI(); | ||
| } | ||
|
|
||
| ESolver_OF_TDDFT::~ESolver_OF_TDDFT() | ||
| { | ||
| delete this->evolve_phi; | ||
| for (int is = 0; is < PARAM.inp.nspin; ++is) | ||
| { | ||
| delete[] this->pphi_td[is]; | ||
| } | ||
| delete[] this->pphi_td; | ||
| } | ||
|
|
||
|
|
||
| void ESolver_OF_TDDFT::runner(UnitCell& ucell, const int istep) | ||
| { | ||
| ModuleBase::timer::tick("ESolver_OF_TDDFT", "runner"); | ||
| // get Ewald energy, initial rho and phi if necessary | ||
| this->before_opt(istep, ucell); | ||
| this->iter_ = 0; | ||
|
|
||
| bool conv_esolver = false; // this conv_esolver is added by mohan 20250302 | ||
| #ifdef __MPI | ||
| this->iter_time = MPI_Wtime(); | ||
| #else | ||
| this->iter_time = std::chrono::system_clock::now(); | ||
| #endif | ||
|
|
||
| if (istep==0) | ||
| { | ||
| this->pphi_td= new std::complex<double>*[PARAM.inp.nspin]; | ||
|
|
||
| for (int is = 0; is < PARAM.inp.nspin; ++is) | ||
| { | ||
| this->pphi_td[is]= new std::complex<double>[pw_rho->nrxx]; | ||
| } | ||
| } | ||
|
|
||
| if ((istep<1) && PARAM.inp.init_chg != "file") | ||
| { | ||
| while (true) | ||
| { | ||
| // once we get a new rho and phi, update potential | ||
| this->update_potential(ucell); | ||
|
|
||
| // calculate the energy of new rho and phi | ||
| this->energy_llast_ = this->energy_last_; | ||
| this->energy_last_ = this->energy_current_; | ||
| this->energy_current_ = this->cal_energy(); | ||
|
|
||
|
|
||
| // check if the job is done | ||
| if (this->check_exit(conv_esolver)) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| // find the optimization direction and step lenghth theta according to the potential | ||
| this->optimize(ucell); | ||
|
|
||
| std::cout<<"optimize------"<<std::endl; | ||
|
|
||
| // update the rho and phi based on the direction and theta | ||
| this->update_rho(); | ||
|
|
||
| this->iter_++; | ||
|
|
||
| ESolver_FP::iter_finish(ucell, istep, this->iter_, conv_esolver); | ||
| } | ||
|
|
||
| for (int is = 0; is < PARAM.inp.nspin; ++is) | ||
| { | ||
| for (int ir = 0; ir < pw_rho->nrxx; ++ir) | ||
| { | ||
| pphi_td[is][ir]=pphi_[is][ir]; | ||
| } | ||
| } | ||
| } | ||
| else | ||
| { | ||
| this->evolve_phi->propagate_psi(this->pelec, this->chr, ucell, this->pphi_td, this->pw_rho); | ||
| for (int is = 0; is < PARAM.inp.nspin; ++is) | ||
| { | ||
| for (int ir = 0; ir < pw_rho->nrxx; ++ir) | ||
| { | ||
| pphi_[is][ir]=abs(pphi_td[is][ir]); | ||
| } | ||
| } | ||
| conv_esolver=true; | ||
| } | ||
|
|
||
| this->after_opt(istep, ucell, conv_esolver); | ||
|
|
||
| ModuleBase::timer::tick("ESolver_OF_TDDFT", "runner"); | ||
| } | ||
|
|
||
| } // namespace ModuleESolver | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #ifndef ESOLVER_OF_TDDFT_H | ||
| #define ESOLVER_OF_TDDFT_H | ||
|
|
||
| #include "esolver_of.h" | ||
| #include "source_pw/module_ofdft/evolve_phi.h" | ||
|
|
||
| namespace ModuleESolver | ||
| { | ||
| class ESolver_OF_TDDFT : public ESolver_OF | ||
| { | ||
| public: | ||
| ESolver_OF_TDDFT(); | ||
| ~ESolver_OF_TDDFT(); | ||
|
|
||
| virtual void runner(UnitCell& ucell, const int istep) override; | ||
|
|
||
| protected: | ||
| std::complex<double>** pphi_td = nullptr; // pphi[i] = ppsi.get_pointer(i), which will be freed in ~Psi(). | ||
| EVOLVE_PHI* evolve_phi=nullptr; | ||
| }; | ||
| } // namespace ModuleESolver | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.