-
Notifications
You must be signed in to change notification settings - Fork 28
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
Adding band structure parser for cp2k version 8.1. #126
Adding band structure parser for cp2k version 8.1. #126
Conversation
Hey @hdsassnick, thanks a lot.
No worries, I think you did a great job. Before I start reviewing the PR, can you please fix the pre-commit issues? It basically just adds two empty lines, see here |
Hi, should work now. |
Hi, I was just wondering if there was any news concerning the review of the pull request. |
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.
Hey @hdsassnick, sorry for the long wait.
I had a closer look at your implementation and I have a couple of suggestions. Generally, I think it would be a good idea to reuse the code that is there already. For instance, the parts of the code that don't work with the 8.1 version of CP2K are:
aiida-cp2k/aiida_cp2k/utils/parser.py
Line 301 in 60d5183
pattern = re.compile(".*?Nr.*?Spin.*?K-Point.*?", re.DOTALL) |
and
aiida-cp2k/aiida_cp2k/utils/parser.py
Lines 312 to 317 in 60d5183
spin = int(splitted[3]) | |
kpoint = tuple(float(p) for p in splitted[-3:]) | |
kpoint_n_lines = int(math.ceil(int(selected_lines[current_line + 1]) / 4)) | |
band = [ | |
float(v) for v in " ".join(selected_lines[current_line + 2:current_line + 2 + kpoint_n_lines]).split() | |
] |
Herein, I think it would be better to modify the _parse_bands
function as follows
def _parse_band_before81(band_lines):
put the old code here
def _parse_band_after81(band_lines):
put the new code here
def _parse_bands(lines, n_start, cp2k_version):
if cp2k_version < 8.1:
pattern = re.compile(".*?Nr.*?Spin.*?K-Point.*?", re.DOTALL)
parse_band_function = _parse_band_before81
else:
pattern = re.compile(".*?Point.*?Spin.*?", re.DOTALL) # didn't try it myself
parse_band_function = _parse_band_after81
I think this approach allows us to write shorter and clearer code.
Let me know if you agree.
Co-authored-by: Aliaksandr Yakutovich <yakutovicha@gmail.com>
Co-authored-by: Aliaksandr Yakutovich <yakutovicha@gmail.com>
Hi @yakutovicha , |
Hi @yakutovicha , I tried to implement your suggestions. I'm not sure if I did it the way you intended. |
@hdsassnick I decided to continue the development a little bit on my own - sorry for that. I just thought that it would be easier for me to implement what I had in mind directly rather than explain what I actually meant.
I think that is a pretty minor difference that could be resolved by employing
Let me know what you think of the current implementation. |
Hi @yakutovicha , |
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.
alright, I think this is ready to go.
Thanks, @hdsassnick for your contribution and for using the plugin. You are very welcome to create issues if something isn't working correctly or issues/PRs in case you want to suggest further improvements!
This will be available in the next minor release of the plugin. |
Hello,
I would firstly like to thank you for the work and effort developing the AiiDA-plugin for cp2k.
It is a great addition to the AiiDA-library and facilitates my work a lot.
I noticed that for the new version 8.1 of cp2k the output format of the band structure has changed and is incompatible with previous versions.
I would like to contribute an adaption of the advanced-output parser which should work with the most recent versions of cp2k
but still keeps the downwards compatibility to older versions of the program.
I would be very happy if the snippet of additional code can be helpful.
This is my first pull request. Apologies if I hadn't done it completely correctly.
Best wishes,
Holger