Skip to content

Commit

Permalink
crystal/base: Deleted unnecessary .as_site_dictionary() method in Cry…
Browse files Browse the repository at this point in the history
…stalBase + associated tests
  • Loading branch information
Somerandomguy10111 committed Jun 30, 2024
1 parent e554379 commit 292de08
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
11 changes: 0 additions & 11 deletions CrystalStructure/crystal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ def calculate_atomic_volume(self) -> float:
def get_non_void_sites(self) -> list[AtomicSite]:
return [site for site in self if not site.is_nonstandard()]

def as_site_dictionaries(self) -> dict:
coordinate_map = {}
for atom_site in self:
coords = (atom_site.x, atom_site.y, atom_site.z)
if not coords in coordinate_map:
coordinate_map[coords] = {}
coordinate_map[coords][atom_site.atom_type] = atom_site.occupancy

print(f'Coordinate map = {coordinate_map}')
return coordinate_map

def is_empty(self) -> bool:
return len(self) == 0

Expand Down
22 changes: 1 addition & 21 deletions tests/t_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,9 @@ def test_scattering_params(self):
for p in params:
self.assertIsInstance(p, float)
if not atomic_site.atom_type in seen_species:
print(f'Scattering params for species \"{atomic_site.atom_type}\" a1, a2, a3, a4, b1, b2, b3, b4 = {params}')
print(f'Scattering params for species \"{atomic_site.species_str}:\n a1, a2, a3, a4, b1, b2, b3, b4 = {params}')
seen_species.add(atomic_site.atom_type)


def test_site_dictionaries(self):
base = CrystalExamples.get_base(mute=False)
site_dictionaries = base.as_site_dictionaries()
coordinates = list(site_dictionaries.keys())

max_err = 10**(-2)
target_coordinate = (0.931,0.25,0)
def dist(coor1, coord2):
return sum([(x-y)**2 for x,y in zip(coor1, coord2)])**(1/2)

match = None
for coord in coordinates:
match_found = any([dist(coord, target_coordinate) < max_err])
if match_found:
match = coord

self.assertIsNotNone(match)
self.assertIn(Species(f'Al0+'), site_dictionaries[match])


if __name__ == '__main__':
TestCrystalBase.execute_all()

0 comments on commit 292de08

Please sign in to comment.