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

Add lattice properties #25

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/pyscal3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,34 @@ def volume(self):
vol = np.dot(np.cross(self._box[0], self._box[1]), self._box[2])
return vol

@property
def lattice_properties(self):
"""
Return lattice properties
"""
if self._structure_dict is not None:
ldict = copy.copy(self._structure_dict)
else:
ldict = {}
if self.atoms._lattice is not None:
ldict['lattice'] = self.atoms._lattice
if self.atoms._lattice_constant is not None:
ldict['lattice_constant'] = self.atoms._lattice_constant
return ldict

@lattice_properties.setter
def lattice_properties(self, ldict):
if self._structure_dict is None:
self._structure_dict = {}

for key, val in ldict.items():
if key in ['species', 'box', 'positions']:
self._structure_dict[key] = val
elif key == 'lattice':
self.atoms._lattice = val
elif key == 'lattice_constant':
self.atoms._lattice_constant = val

@property
def atoms(self):
return self._atoms
Expand Down
Loading