Skip to content

Commit c0bd98c

Browse files
authored
Merge pull request #11 from PytLab/add-poscar-cartesian-coordinate
Add cartesian coord in get_poscar_content
2 parents ecb6f47 + de7931b commit c0bd98c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

vaspy/atomco.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ def get_poscar_content(self, **kwargs):
159159
atom_types = ("{:>5s}"*len(types) + "\n").format(*types)
160160
atom_numbers = ("{:>5d}"*len(numbers) + "\n").format(*numbers)
161161

162+
# Direct or Cartesian
163+
coord_type = kwargs.get('coord_type', 'direct')
164+
162165
# string
163-
info = "Selective Dynamics\nDirect\n"
166+
if coord_type == 'direct':
167+
info = "Selective Dynamics\nDirect\n"
168+
else:
169+
info = "Cartensian\n"
164170

165171
# data and tf
166172
try:
@@ -170,7 +176,12 @@ def get_poscar_content(self, **kwargs):
170176
default_tf = np.full(self.data.shape, 'T', dtype=np.str)
171177
tf = kwargs.get("tf", default_tf)
172178
data_tf = ''
173-
for data, tf in zip(self.data.tolist(), tf.tolist()):
179+
if coord_type == 'direct':
180+
data = self.data.tolist()
181+
else:
182+
data = self.dir2cart(self.bases, self.data).tolist()
183+
184+
for data, tf in zip(data, tf.tolist()):
174185
data_tf += ("{:18.12f}"*3 + "{:>5s}"*3 + "\n").format(*(data+tf))
175186

176187
# merge all strings

0 commit comments

Comments
 (0)