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

Support integer cell params #71

Merged
merged 4 commits into from
Oct 18, 2023
Merged

Support integer cell params #71

merged 4 commits into from
Oct 18, 2023

Conversation

eimrek
Copy link
Member

@eimrek eimrek commented Oct 17, 2023

We had a Materials Cloud seekpath tool user complain that a valid QE input is not working [1].

I looked into it, and it seemed to come from the fact that the zeroes were integers (no decimal point).

Same issue has arisen a while ago: fixes #51

Took a while to go through the regexes, but the issue stems from here

(
\s+ # White space between numbers
[-|+]? # Plus or minus in front of the number (optional)
(\d* # optional decimal in the beginning .0001 is ok, for example
[\.] # There has to be a dot followed by
\d+) # at least one decimal
| # OR
(\d+ # at least one decimal, followed by
[\.]? # an optional dot
\d*) # followed by optional decimals
([E|e|d|D][+|-]?\d+)? # optional exponents E+03, e-05, d0, D0
){2} # I expect three float values

This matches 1) \s+ (whitespace); and 2) a number. Not fully sure why, but if i add extra parentheses around the number part, everything works correctly.

But together with this issue, i refactored the whole script a bit, as this number-matching-pattern was duplicated in many places. I defined it as a constant, added parenthesis around it, so it's safe and just used that constant everywhere a number needed to be matched. i think it's more understandable and maintainable this way.

Additionally i added a test that would have failed before.

cc @giovannipizzi

[1]:

&control
    outdir = './out_nacl'
    prefix = 'nacl'
    calculation = 'scf'
    tprnfor = .true.
    tstress = .true.
    pseudo_dir = './pseudo/'
 /
 &system
    ibrav = 0
    nat = 8
    ntyp = 2
    ecutwfc = 70.0
 /
 &electrons
    diagonalization = 'david'
    conv_thr = 1.0d-9
 /
ATOMIC_SPECIES
 Na  22.98976928 Na.paw.z_9.ld1.psl.v1.0.0-low.upf
 Cl  35.453      Cl.pbe-n-rrkjus_psl.1.0.0.UPF
ATOMIC_POSITIONS crystal
 Na   0.0000000000000000  0.0000000000000000  0.0000000000000000
 Na   0.0000000000000000  0.5000000000000000  0.5000000000000000
 Na   0.5000000000000000  0.0000000000000000  0.5000000000000000
 Na   0.5000000000000000  0.5000000000000000  0.0000000000000000
 Cl   0.5000000000000000  0.5000000000000000  0.5000000000000000
 Cl   0.5000000000000000  0.0000000000000000  0.0000000000000000
 Cl   0.0000000000000000  0.5000000000000000  0.0000000000000000
 Cl   0.0000000000000000  0.0000000000000000  0.5000000000000000
CELL_PARAMETERS angstrom
 5.6903014761756712 0 0
 0 5.6903014761756712 0
 0 0 5.6903014761756712
K_POINTS automatic
8 8 8 1 1 1

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ee3f7d7) 89.87% compared to head (b2a5657) 89.89%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   89.87%   89.89%   +0.02%     
==========================================
  Files          10       10              
  Lines         464      465       +1     
==========================================
+ Hits          417      418       +1     
  Misses         47       47              
Files Coverage Δ
src/qe_tools/parsers/_input_base.py 88.25% <100.00%> (+0.03%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eimrek eimrek requested a review from sphuber October 17, 2023 13:00
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eimrek changes to the regex look ok to me. Just a suggestion for cleaning up the test a bit

tests/data/lattice_ibrav0_cell_parameters_int.in Outdated Show resolved Hide resolved
@eimrek eimrek requested a review from sphuber October 17, 2023 21:37
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eimrek

@sphuber sphuber merged commit efe4472 into main Oct 18, 2023
10 checks passed
@sphuber sphuber deleted the fix-int-cell-params branch October 18, 2023 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing PW input file
3 participants