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 element count within each coordination number #64

Open
bobleesj opened this issue Oct 29, 2024 · 1 comment
Open

Add element count within each coordination number #64

bobleesj opened this issue Oct 29, 2024 · 1 comment

Comments

@bobleesj
Copy link
Owner

Problem

While it has been implemented manually in SAF for binary and ternary, we want to automate this for all .cif files.

@bobleesj
Copy link
Owner Author

bobleesj commented Oct 29, 2024

def get_element_count_in_CN(central_atom_site_label: str, cif):
    # Retrieve CN connections for the given atomic site label
    CN_connections = cif.CN_connections_by_min_dist_method[central_atom_site_label]
    
    # Initialize an empty dictionary to count occurrences of each element
    element_count = {}
    
    # Iterate over each connection tuple in CN_connections
    for connection in CN_connections:
        # Extract the label (e.g., 'Se1', 'Li2') from the connection
        connected_atomic_label = connection[0]
        
        # Extract only the element part (e.g., 'Se', 'Li') from the label
        element = string_parser.get_atom_type_from_label(connected_atomic_label)
        
        # Increment the count for this element in the dictionary
        if element in element_count:
            element_count[element] += 1
        else:
            element_count[element] = 1
    
    return element_count

pretty simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant