Commit 119f4bac authored by Lan Huang's avatar Lan Huang
Browse files

add fun view and addFracCoordAtom

parent fb597c5f
...@@ -150,6 +150,29 @@ class Geometry(object) : ...@@ -150,6 +150,29 @@ class Geometry(object) :
self.atoms.append( Atom(symbol, position, units) ) self.atoms.append( Atom(symbol, position, units) )
self.isSet["atoms"] = True self.isSet["atoms"] = True
# #
def addFracCoordAtom(self, symbol, frac_coord):
"""adds a single atom by fractional coords
:param symbol: chemical symbol
:type symbol: string
:param position: position
:type position: 3-dim tuple
>>> from westpy import *
>>> geom = Geometry()
>>> geom.addFracCoordAtom( "Si", (0,1/3.0,2/3.0) )
if not self.isSet["cell"]:
print('Set cell first!')
import numpy as np
from westpy import Atom, Bohr
M = np.matrix([self.cell['a1'], self.cell['a2'], self.cell['a3']]).tolist()
self.atoms.append(Atom(symbol, tuple(np.array(frac_coord)@M), units=Bohr))
self.isSet["atoms"] = True
def __addAtomsFromXYZLines(self, lines, decode=True ) : def __addAtomsFromXYZLines(self, lines, decode=True ) :
"""Adds atoms from XYZ lines. """Adds atoms from XYZ lines.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment