forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 145
Update the output and readin of electronic wave functions in plane wave basis set #6223
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
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a5cf8aa
update the readin wave function information
mohanchen c7b6a5f
remove the extra write_wfc_pw in esolver_ks_pw
mohanchen b144abf
let GPU OW test passes
mohanchen 11e4bb4
update the output formats of pw wave functions
mohanchen cf6cd98
update pw readin wf, found 2 places that read in wave functions, need…
mohanchen 2cc5297
update 055 example
mohanchen bb82fb4
update doc
mohanchen 6fcf3fa
update input files and fix compilation error
mohanchen 8456ef6
update input-main.md
mohanchen 886f6ca
update 090 example
mohanchen 1b0072c
update 090 example
mohanchen 487205a
update some tests in 01
mohanchen 199e138
update CASES
mohanchen a5da637
update file names in 08_EXX example
mohanchen 03f570e
I found read_wfc_lcao code and the corresponding tests are useless
mohanchen d94984f
update test.yml
mohanchen a06bb28
update read_wf2rho_pw function and tests
mohanchen b9b415d
rewrite the input variables for write_wfc_pw
mohanchen 61e6552
update read_wfc_pw
mohanchen a1abaa1
remove ofs_running info
mohanchen cd7e2cf
fix read_wf2rho_pw_test.cpp
mohanchen c5b4ebb
fix bug
mohanchen 01232f4
update read_input_ptest.cpp test
mohanchen fd81a76
add back wfs1k1_pw.dat
mohanchen e5692d2
update 055_PW_OW result.ref
mohanchen 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
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,111 @@ | ||
| #include <set> | ||
| #include "filename.h" | ||
| #include "module_base/tool_quit.h" | ||
|
|
||
| namespace ModuleIO | ||
| { | ||
|
|
||
| std::string filename_output( | ||
| const std::string &directory, | ||
| const std::string &property, | ||
| const std::string &basis, | ||
| const int ik_local, // the ik index within each pool | ||
| const std::vector<int> &ik2iktot, | ||
| const int nspin, | ||
| const int nkstot, | ||
| const int out_type, | ||
| const bool out_app_flag, | ||
| const bool gamma_only, | ||
| const int istep) | ||
| { | ||
| // output filename = "{PARAM.globalv.global_out_dir}/property{s}{spin index} | ||
| // {k(optinal)}{k-point index}{g(optional)}{geometry index1}{_basis(nao|pw)} | ||
| // + {".txt"/".dat"}" | ||
|
|
||
| std::set<std::string> valid_properties = {"wf", "chg", "h", "s"}; | ||
| if (valid_properties.find(property) == valid_properties.end()) | ||
| { | ||
| ModuleBase::WARNING_QUIT("ModuleIO::filename_output", "unknown property"); | ||
| } | ||
|
|
||
| std::set<std::string> valid_basis = {"pw", "nao"}; | ||
| if (valid_basis.find(basis) == valid_basis.end()) | ||
| { | ||
| ModuleBase::WARNING_QUIT("ModuleIO::filename_output", "unknown basis"); | ||
| } | ||
|
|
||
| assert(ik_local>=0); | ||
| // mohan update 2025.05.07, if KPAR>1, "<" works | ||
| assert(ik2iktot.size() <= nkstot); | ||
| assert(nspin>0); | ||
|
|
||
| // spin index | ||
| int is0 = -1; | ||
| // ik0 is the k-point index, starting from 0 | ||
| int ik0 = ik2iktot[ik_local]; | ||
|
|
||
| if(nspin == 1) | ||
| { | ||
| is0 = 1; | ||
| } | ||
| else if(nspin == 2) | ||
| { | ||
| const int half_k = nkstot/2; | ||
| if(ik0 >= half_k) | ||
| { | ||
| is0 = 2; | ||
| ik0 -= half_k; | ||
| } | ||
| else | ||
| { | ||
| is0 = 1; | ||
| } | ||
| } | ||
| else if(nspin==4) | ||
| { | ||
| is0 = 12; | ||
| } | ||
|
|
||
| // spin part | ||
| std::string spin_block; | ||
| spin_block = "s" + std::to_string(is0); | ||
|
|
||
| // k-point part | ||
| std::string kpoint_block; | ||
| if(gamma_only) | ||
| { | ||
| // do nothing; | ||
| } | ||
| else | ||
| { | ||
| kpoint_block = "k" + std::to_string(ik0+1); | ||
| } | ||
|
|
||
| std::string istep_block | ||
| = (istep >= 0 && (!out_app_flag)) | ||
| ? "g" + std::to_string(istep + 1) | ||
| : ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file | ||
|
|
||
| std::string suffix_block; | ||
| if (out_type == 1) | ||
| { | ||
| suffix_block = ".txt"; | ||
| } | ||
| else if (out_type == 2) | ||
| { | ||
| suffix_block = ".dat"; | ||
| } | ||
| else | ||
| { | ||
| std::cout << "WARNING: the type of output wave function is not 1 or 2, so 1 is chosen." << std::endl; | ||
| suffix_block = ".txt"; | ||
| } | ||
|
|
||
| std::string fn_out | ||
| = directory + property + spin_block + kpoint_block | ||
| + istep_block + "_" + basis + suffix_block; | ||
|
|
||
| return fn_out; | ||
| } | ||
|
|
||
| } |
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,38 @@ | ||
| #ifndef FILENAME_H | ||
| #define FILENAME_H | ||
| #include <vector> | ||
| #include <string> | ||
|
|
||
| namespace ModuleIO | ||
| { | ||
|
|
||
| /** | ||
| * Generates the filename for the output files | ||
| * @param directory: directory of the file | ||
| * @param property: wave function (wf), charge density (chg) or matrix (mat) | ||
| * @param basis: nao or pw | ||
| * @param ik_local: index of the k-points within each pool, and starting from 0. | ||
| * @param ik2iktot: map from ik to iktot | ||
| * @param nspin: number of spin channels, 1,2 or 4 | ||
| * @param nkstot: number of total k-points | ||
| * @param out_type: two types of output file format, 1 for .txt and 2 for .dat (binary) | ||
| * @param out_app_flag: whether to append to existing file. | ||
| * @param gamma_only: gamma_only algorithm or not. | ||
| * @param istep: index of the ion step starting from 0. If < 0, the step number is not included in the file name. | ||
| * @return The generated filename. | ||
| */ | ||
| std::string filename_output( | ||
| const std::string &directory, | ||
| const std::string &property, | ||
| const std::string &basis, | ||
| const int ik_local, | ||
| const std::vector<int> &ik2iktot, | ||
| const int nspin, | ||
| const int nkstot, | ||
| const int out_type, | ||
| const bool out_app_flag, | ||
| const bool gamma_only, | ||
| const int istep=-1); | ||
|
|
||
| } | ||
| #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
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.