From bec814943292d10344e309bd48594c6f31d51141 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Thu, 15 Jun 2023 16:18:11 -0700 Subject: [PATCH 1/2] Update CifWriter Change the atom site type symbol, such that the element symbol is saved instead of the full species string (which includes site properties) --- pymatgen/io/cif.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymatgen/io/cif.py b/pymatgen/io/cif.py index 303ff71a301..de55e97eb38 100644 --- a/pymatgen/io/cif.py +++ b/pymatgen/io/cif.py @@ -1326,7 +1326,7 @@ def __init__( if symprec is None: for site in struct: for sp, occu in sorted(site.species.items()): - atom_site_type_symbol.append(str(sp)) + atom_site_type_symbol.append(str(sp.symbol)) atom_site_symmetry_multiplicity.append("1") atom_site_fract_x.append(format_str.format(site.a)) atom_site_fract_y.append(format_str.format(site.b)) @@ -1363,7 +1363,7 @@ def __init__( ), ): for sp, occu in site.species.items(): - atom_site_type_symbol.append(str(sp)) + atom_site_type_symbol.append(str(sp.symbol)) atom_site_symmetry_multiplicity.append(f"{mult}") atom_site_fract_x.append(format_str.format(site.a)) atom_site_fract_y.append(format_str.format(site.b)) From c35d764ff3501996a30edc6cb3315c3495d4b4c2 Mon Sep 17 00:00:00 2001 From: Ronald Kam Date: Thu, 15 Jun 2023 17:19:41 -0700 Subject: [PATCH 2/2] Update CifWriter to save species with oxi state atom_site_type_symbol now saves the element and oxidation state, without the other site properties --- pymatgen/io/cif.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pymatgen/io/cif.py b/pymatgen/io/cif.py index de55e97eb38..8b94a157efb 100644 --- a/pymatgen/io/cif.py +++ b/pymatgen/io/cif.py @@ -4,6 +4,7 @@ from __future__ import annotations +import copy import math import os import re @@ -1326,7 +1327,9 @@ def __init__( if symprec is None: for site in struct: for sp, occu in sorted(site.species.items()): - atom_site_type_symbol.append(str(sp.symbol)) + sp_no_prop = copy.deepcopy(sp) + sp_no_prop._properties = {} + atom_site_type_symbol.append(str(sp_no_prop)) atom_site_symmetry_multiplicity.append("1") atom_site_fract_x.append(format_str.format(site.a)) atom_site_fract_y.append(format_str.format(site.b)) @@ -1363,7 +1366,9 @@ def __init__( ), ): for sp, occu in site.species.items(): - atom_site_type_symbol.append(str(sp.symbol)) + sp_no_prop = copy.deepcopy(sp) + sp_no_prop._properties = {} + atom_site_type_symbol.append(str(sp_no_prop)) atom_site_symmetry_multiplicity.append(f"{mult}") atom_site_fract_x.append(format_str.format(site.a)) atom_site_fract_y.append(format_str.format(site.b))