Repository navigation
feat(dfpt): QE-format dynamical matrix file output (dfpt_out_dyn) #8240
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
base: develop
Are you sure you want to change the base?
Changes from all commits
c898530
93b3c77
fd60489
5d0c79b
2e43b0a
ae3486e
ef47808
02690c8
b51b0b1
b67aebb
0334952
179df9b
493708f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -524,6 +524,36 @@ void DFPT_PW_Data::set_dynmat(int q_idx, const ModuleBase::ComplexMatrix& dm) | |
| ModuleBase::timer::end("DFPT_PW_Data", "set_dynmat"); | ||
| } | ||
|
|
||
| void DFPT_PW_Data::set_dynmat_raw(int q_idx, const ModuleBase::ComplexMatrix& dm) | ||
| { | ||
| ModuleBase::TITLE("DFPT_PW_Data", "set_dynmat_raw"); | ||
| ModuleBase::timer::start("DFPT_PW_Data", "set_dynmat_raw"); | ||
| if (q_idx >= static_cast<int>(dynmat_raw_.size())) | ||
| { | ||
| dynmat_raw_.resize(q_idx + 1); | ||
| } | ||
| dynmat_raw_[q_idx] = dm; | ||
|
Comment on lines
+531
to
+535
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: the extra dense matrix per q and its copies are retained even with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up. The raw copy is a nat²×9 complex matrix per q — negligible for the current validation set (2-6 atoms). A retention flag can be added if larger systems make this measurable. |
||
| ModuleBase::timer::end("DFPT_PW_Data", "set_dynmat_raw"); | ||
| } | ||
|
|
||
| ModuleBase::ComplexMatrix DFPT_PW_Data::get_dynmat_raw(int q_idx) const | ||
| { | ||
| ModuleBase::TITLE("DFPT_PW_Data", "get_dynmat_raw"); | ||
| ModuleBase::timer::start("DFPT_PW_Data", "get_dynmat_raw"); | ||
| if (q_idx < static_cast<int>(dynmat_raw_.size()) && dynmat_raw_[q_idx].nr > 0) | ||
| { | ||
| ModuleBase::timer::end("DFPT_PW_Data", "get_dynmat_raw"); | ||
| return dynmat_raw_[q_idx]; | ||
| } | ||
| ModuleBase::timer::end("DFPT_PW_Data", "get_dynmat_raw"); | ||
| return get_dynmat(q_idx); // fallback: the working copy | ||
| } | ||
|
|
||
| bool DFPT_PW_Data::has_dynmat_raw(int q_idx) const | ||
| { | ||
| return q_idx >= 0 && q_idx < static_cast<int>(dynmat_raw_.size()) && dynmat_raw_[q_idx].nr > 0; | ||
| } | ||
|
|
||
| ModuleBase::ComplexMatrix DFPT_PW_Data::get_dynmat(int q_idx) const | ||
| { | ||
| ModuleBase::TITLE("DFPT_PW_Data", "get_dynmat"); | ||
|
|
@@ -633,6 +663,7 @@ void DFPT_PW_Data::deallocate_memory() | |
| ModuleBase::TITLE("DFPT_PW_Data", "deallocate_memory"); | ||
| ModuleBase::timer::start("DFPT_PW_Data", "deallocate_memory"); | ||
| dynmat_.clear(); | ||
| dynmat_raw_.clear(); | ||
| phon_freq_.clear(); | ||
| born_.clear(); | ||
| docc_.clear(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,13 @@ class DFPT_PW_Data | |
| /// through the LapackConnector::zheev wrapper. | ||
| void set_dynmat(int q_idx, const ModuleBase::ComplexMatrix& dm); | ||
| ModuleBase::ComplexMatrix get_dynmat(int q_idx) const; | ||
|
|
||
| /// stash the raw (pre-ASR, pre-LO-TO) dynamical matrix for the dyn | ||
| /// file output; the working dynmat_ is mutated in place by apply_asr | ||
| /// and add_loto at Gamma, so the file writer needs this untouched copy | ||
| void set_dynmat_raw(int q_idx, const ModuleBase::ComplexMatrix& dm); | ||
| ModuleBase::ComplexMatrix get_dynmat_raw(int q_idx) const; | ||
| bool has_dynmat_raw(int q_idx) const; | ||
| void set_phon_freq(int q_idx, const std::vector<double>& freq); | ||
| std::vector<double> get_phon_freq(int q_idx) const; | ||
|
|
||
|
|
@@ -281,6 +288,8 @@ class DFPT_PW_Data | |
| std::vector<std::vector<std::vector<std::complex<double>>>> dv_rc_; | ||
|
|
||
| std::vector<ModuleBase::ComplexMatrix> dynmat_; | ||
| /// pre-ASR / pre-LO-TO copies for the dyn file output ([q]) | ||
| std::vector<ModuleBase::ComplexMatrix> dynmat_raw_; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: clear
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in b51b0b1: |
||
| std::vector<std::vector<double>> phon_freq_; | ||
|
|
||
| bool compute_q0_ = false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: add
test_dfpt_write_dyn.cppand raw-state tests covering an independently specified QE record fixture, raw preservation through ASR/LO-TO, andcompute_q0=truewith LO-TO disabled. The existing checked-in phonon tests do not call this writer or check its new raw-storage contract.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up. A write-read-back round-trip test is planned once the format is confirmed stable through cross-code validation.