Skip to content

Commit

Permalink
chore: some more test for robocrys
Browse files Browse the repository at this point in the history
  • Loading branch information
n0w0f committed Feb 12, 2024
1 parent 70fd970 commit 97cd505
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 1 deletion.
37 changes: 37 additions & 0 deletions tests/data/SrTiO3_p1.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# generated using pymatgen
data_SrTiO3
_symmetry_space_group_name_H-M 'P 1'
_cell_length_a 3.91270131
_cell_length_b 3.91270131
_cell_length_c 3.91270131
_cell_angle_alpha 90.00000000
_cell_angle_beta 90.00000000
_cell_angle_gamma 90.00000000
_symmetry_Int_Tables_number 1
_chemical_formula_structural SrTiO3
_chemical_formula_sum 'Sr1 Ti1 O3'
_cell_volume 59.90045031
_cell_formula_units_Z 1
loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 'x, y, z'
loop_
_atom_type_symbol
_atom_type_oxidation_number
Sr2+ 2.0
Ti4+ 4.0
O2- -2.0
loop_
_atom_site_type_symbol
_atom_site_label
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
Sr2+ Sr0 1 0.00000000 0.00000000 0.00000000 1
Ti4+ Ti1 1 0.50000000 0.50000000 0.50000000 1
O2- O2 1 0.50000000 0.00000000 0.50000000 1
O2- O3 1 0.50000000 0.50000000 0.00000000 1
O2- O4 1 0.00000000 0.50000000 0.50000000 1
82 changes: 82 additions & 0 deletions tests/data/SrTiO3_symmetrized.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# generated using pymatgen
data_SrTiO3
_symmetry_space_group_name_H-M Pm-3m
_cell_length_a 3.91270131
_cell_length_b 3.91270131
_cell_length_c 3.91270131
_cell_angle_alpha 90.00000000
_cell_angle_beta 90.00000000
_cell_angle_gamma 90.00000000
_symmetry_Int_Tables_number 221
_chemical_formula_structural SrTiO3
_chemical_formula_sum 'Sr1 Ti1 O3'
_cell_volume 59.90045031
_cell_formula_units_Z 1
loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 'x, y, z'
2 '-x, -y, -z'
3 '-y, x, z'
4 'y, -x, -z'
5 '-x, -y, z'
6 'x, y, -z'
7 'y, -x, z'
8 '-y, x, -z'
9 'x, -y, -z'
10 '-x, y, z'
11 '-y, -x, -z'
12 'y, x, z'
13 '-x, y, -z'
14 'x, -y, z'
15 'y, x, -z'
16 '-y, -x, z'
17 'z, x, y'
18 '-z, -x, -y'
19 'z, -y, x'
20 '-z, y, -x'
21 'z, -x, -y'
22 '-z, x, y'
23 'z, y, -x'
24 '-z, -y, x'
25 '-z, x, -y'
26 'z, -x, y'
27 '-z, -y, -x'
28 'z, y, x'
29 '-z, -x, y'
30 'z, x, -y'
31 '-z, y, x'
32 'z, -y, -x'
33 'y, z, x'
34 '-y, -z, -x'
35 'x, z, -y'
36 '-x, -z, y'
37 '-y, z, -x'
38 'y, -z, x'
39 '-x, z, y'
40 'x, -z, -y'
41 '-y, -z, x'
42 'y, z, -x'
43 '-x, -z, -y'
44 'x, z, y'
45 'y, -z, -x'
46 '-y, z, x'
47 'x, -z, y'
48 '-x, z, -y'
loop_
_atom_type_symbol
_atom_type_oxidation_number
Sr2+ 2.0
Ti4+ 4.0
O2- -2.0
loop_
_atom_site_type_symbol
_atom_site_label
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
Sr2+ Sr0 1 0.00000000 0.00000000 0.00000000 1
Ti4+ Ti1 1 0.50000000 0.50000000 0.50000000 1
O2- O2 3 0.00000000 0.50000000 0.50000000 1
8 changes: 7 additions & 1 deletion tests/test_textrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
THIS_DIR = os.path.dirname(os.path.abspath(__file__))

N2 = TextRep.from_input(os.path.join(THIS_DIR, "data", "N2.cif"))
srtio3_p1 = TextRep.from_input(os.path.join(THIS_DIR, "data", "SrTiO3_p1.cif"))
srtio3_symmetrized = TextRep.from_input(os.path.join(THIS_DIR, "data", "SrTiO3_symmetrized.cif"))


def test_get_cif_string() -> None:
Expand All @@ -28,6 +30,10 @@ def test_get_crystal_llm_rep() -> None:
expected_output = "5.6 5.6 5.6\n90 90 90\nN0+\n0.48 0.98 0.52\nN0+\n0.98 0.52 0.48\nN0+\n0.02 0.02 0.02\nN0+\n0.52 0.48 0.98"
assert N2.get_crystal_llm_rep() == expected_output

def test_robocrys_for_cif_format() -> None:
assert srtio3_p1.get_robocrys_rep() == srtio3_symmetrized.get_robocrys_rep()

def test_get_robocrys_rep() -> None:
excepted_output = "N2 is Indium-like structured and crystallizes in the cubic P2_13 space group. The structure is zero-dimensional and consists of four ammonia atoms. N(1) is bonded in a 1-coordinate geometry to atoms."
assert N2.get_robocrys_rep() == excepted_output
assert N2.get_robocrys_rep() == excepted_output

0 comments on commit 97cd505

Please sign in to comment.