-
Notifications
You must be signed in to change notification settings - Fork 179
Enhance poscar_scale function (/data/gen.py)to detect Selective dynamics #1439
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: devel
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -237,12 +237,24 @@ | |||||||||||||||||||
def poscar_scale(poscar_in, poscar_out, scale): | ||||||||||||||||||||
with open(poscar_in) as fin: | ||||||||||||||||||||
lines = list(fin) | ||||||||||||||||||||
if "D" == lines[7][0] or "d" == lines[7][0]: | ||||||||||||||||||||
|
||||||||||||||||||||
# Determine if "Selective dynamics" is present | ||||||||||||||||||||
if lines[7].strip().lower().startswith("s"): | ||||||||||||||||||||
njzjz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
coord_type_line = 8 # If present, coordinates type is on line 9 | ||||||||||||||||||||
else: | ||||||||||||||||||||
coord_type_line = 7 # If not, coordinates type is on line 8 | ||||||||||||||||||||
njzjz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
|
||||||||||||||||||||
# Process according to the coordinate type | ||||||||||||||||||||
if "D" == lines[coord_type_line][0] or "d" == lines[coord_type_line][0]: | ||||||||||||||||||||
lines = poscar_scale_direct(lines, scale) | ||||||||||||||||||||
elif "C" == lines[7][0] or "c" == lines[7][0]: | ||||||||||||||||||||
elif "C" == lines[coord_type_line][0] or "c" == lines[coord_type_line][0]: | ||||||||||||||||||||
lines = poscar_scale_cartesian(lines, scale) | ||||||||||||||||||||
Comment on lines
+248
to
251
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. Suggestion: Use the
Suggested change
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. I agree with this comment
njzjz marked this conversation as resolved.
Show resolved
Hide resolved
njzjz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
else: | ||||||||||||||||||||
raise RuntimeError("Unknow poscar style at line 7: %s" % lines[7]) | ||||||||||||||||||||
raise RuntimeError( | ||||||||||||||||||||
f"Unknown poscar style at line {coord_type_line + 1}: {lines[coord_type_line]}" | ||||||||||||||||||||
) | ||||||||||||||||||||
Comment on lines
+253
to
+255
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. Suggestion: The error message in the
Suggested change
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. So, is it poscar style or coordinate type? |
||||||||||||||||||||
|
||||||||||||||||||||
# Write scaled positions back to output file | ||||||||||||||||||||
with open(poscar_out, "w") as fout: | ||||||||||||||||||||
fout.write("".join(lines)) | ||||||||||||||||||||
|
||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.