pymatgen icon indicating copy to clipboard operation
pymatgen copied to clipboard

printing labels from PeriodicSite in cif file

Open AndresOrtegaGuerrero opened this issue 1 year ago • 0 comments

Python version

3.12.1

Pymatgen version

2024.3.1

Operating system version

No response

Current behavior

Hello Developers, When defying a Structure where the periodicSites have an specific label , the cif file that is print by CifWriter doesnt use the labels when one is None,

from pymatgen.core import Lattice, Structure, Molecule from pymatgen.io.cif import CifWriter

coords = [[0, 0, 0], [0.75,0.5,0.75]] lattice = Lattice.from_parameters(a=3.84, b=3.84, c=3.84, alpha=120, beta=90, gamma=60) struct = Structure(lattice, ["Si", "Si"], coords) struct.sites[0].label = "Si1"

cif_writer = CifWriter(struct) cif_writer.write_file("output.cif")

I obtained,

_cell_angle_beta 90.00000000 _cell_angle_gamma 60.00000000 _symmetry_Int_Tables_number 1 _chemical_formula_structural Si _chemical_formula_sum Si2 _cell_volume 40.03858081 cell_formula_units_Z 2 loop _symmetry_equiv_pos_site_id symmetry_equiv_pos_as_xyz 1 'x, y, z' 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 Si Si1 1 0.00000000 0.00000000 0.00000000 1 Si Si1 1 0.75000000 0.50000000 0.75000000 1

Expected Behavior

I should expect

_cell_angle_beta 90.00000000 _cell_angle_gamma 60.00000000 _symmetry_Int_Tables_number 1 _chemical_formula_structural Si _chemical_formula_sum Si2 _cell_volume 40.03858081 cell_formula_units_Z 2 loop _symmetry_equiv_pos_site_id symmetry_equiv_pos_as_xyz 1 'x, y, z' 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 Si Si1 1 0.00000000 0.00000000 0.00000000 1 Si Si 1 0.75000000 0.50000000 0.75000000 1

Minimal example

No response

Relevant files to reproduce this bug

No response

AndresOrtegaGuerrero avatar Mar 22 '24 12:03 AndresOrtegaGuerrero