Looking at the 'search API', I can't find any code that allows to construction of a Z/Density query (similar to Conquest) with the current ccdc Python module. Am I missing an important class here or is this functionality missing in the module? Queries like this one could be extremely useful in my project (working with multicomponent systems).

Kind regards,

Jan-Joris Devogelaer

Hi Jan-Joris,

I'm afraid we have not implemented this sort of search in the API.  The rather clumsy work-around is to scan the whole CSD with the required criteria, for example:

from ccdc import io

csd = io.CrystalReader('csd')
refcodes = []
for c in csd:
    if c.z_value == required_z and c.z_prime == required_z_prime and c.calculated_density is not None and low_density < c.calculated_density < high_density:
        m = c.molecule
        if len(m.components) == required_components:
            atoms_with_sites = [a for a in m.atoms if a.coordinates is not None]
            if len(atoms_with_sites) == required_sited_atoms:

with open('hit_structures.gcd', 'w') as writer:

I'm sorry that there is nothing faster available in the API: I shall raise this at the next scheduling meeting to see whether it can be implemented for a future release.

Thank you for the question: it is feedback like this that helps to make the API better.

Best wishes

You must be signed in to post in this forum.