You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for this incredible library!
Python version
Python 3.12.7
Pymatgen version
2024.11.13
Operating system version
Pop!_OS 22.04 LTS
Current behavior
Steps to reproduce
define structure in cartesian coords
create Poscar object from structure
wirte poscar to file
-⚡ POSCAR file contains cartesian coords with a vasp flag direct
-⚡ POSCAR __repr__ & __str__ show direct coords.
Expected Behavior
POSCAR file contains cartesian coords with a vasp flag cartesian
POSCAR __repr__ & __str__ shows cartesian coords.
Additional info
Imho, this is a contrintuitive behavior.
In order for this to work one should explicitly call poscar.write_file() with direct=False argument: poscar.write_file("POSCAR", direct=False). However, it will not affect __repr__ & __str__ behavior. Reason being: direct property is not passed to dunder methods, but is overwritten by default get_str declaration.
"""Write POSCAR to a file. The supported kwargs are the same as those for
the Poscar.get_str method and are passed through directly.
"""
withzopen(filename, mode="wt") asfile:
file.write(self.get_str(**kwargs))
Minimal example
frompymatgen.io.vaspimportPoscarfrompymatgen.coreimportStructure, Latticelattice=Lattice.cubic(10.0)
species= ["Al"] # Single aluminum atomcoords= [[0, 0, 0]] # Position of the atom in Cartesian coordinatesstructure=Structure(
lattice,
species,
coords,
coords_are_cartesian=False,
)
poscar=Poscar(structure)
poscar.write_file("POSCAR")
The text was updated successfully, but these errors were encountered:
Erm, I am not sure what you mean. I don't think you can use 0, 0, 0 as the example. Those coordinates are the same whether in direct or cartesian coords by definition. Also, your code is confusing because your comment says "Position of the atom in Cartesian coordinates" and yet you set coords_are_cartesian to False. Those are contradictory.
You will need to show an example where the Cartesian coords lead to the wrong direct coordinates. The Poscar always write direct coordinates by default because that is usually the way people define coordinates in crystals. But you can set cartesian output if you'd like.
First of all, thank you for this incredible library!
Python version
Python 3.12.7
Pymatgen version
2024.11.13
Operating system version
Pop!_OS 22.04 LTS
Current behavior
Steps to reproduce
-⚡ POSCAR file contains cartesian coords with a vasp flag
direct
-⚡ POSCAR
__repr__
&__str__
showdirect
coords.Expected Behavior
cartesian
__repr__
&__str__
showscartesian
coords.Additional info
Imho, this is a contrintuitive behavior.
In order for this to work one should explicitly call
poscar.write_file()
withdirect=False
argument:poscar.write_file("POSCAR", direct=False)
. However, it will not affect__repr__
&__str__
behavior. Reason being:direct
property is not passed to dunder methods, but is overwritten by defaultget_str
declaration.pymatgen/src/pymatgen/io/vasp/inputs.py
Lines 158 to 163 in 31f1e1f
pymatgen/src/pymatgen/io/vasp/inputs.py
Lines 565 to 570 in 31f1e1f
pymatgen/src/pymatgen/io/vasp/inputs.py
Lines 656 to 661 in 31f1e1f
Minimal example
The text was updated successfully, but these errors were encountered: