Adding binary observer afterwards

I ran an MC with an attached CE I wrote out a structure every MC step is it possible to use the BinaryShortRangeOrderObserver with this data?

I read my ClusterExpansion-file and XDATCAR-file I used in the KMC I then initalized the BinaryShortRangeOrderObserver with the ClusterSpace read from the CE the first Structure of the XDATCAR the pair-radius (the biggest radius) of my ClusterExpansion but I get an

RuntimeError: Failed to find site by position (findLatticeSiteByPosition).

Full Error Message:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[4], line 18, in analyze(xdatcar_path)
     15 sro_parameters = []
     17 # Setting up Observer
---> 18 sro = BinaryShortRangeOrderObserver(
     19     cluster_space=cs,
     20     structure=structures[0],
     21     radius=8.09 ) 
     23 # Process each structure-snapshot
     24 for i, structure in enumerate(structures):

File ~/anaconda3/lib/python3.10/site-packages/mchammer/observers/binary_short_range_order_observer.py:93, in BinaryShortRangeOrderObserver.__init__(self, cluster_space, structure, radius, interval)
     88 super().__init__(interval=interval, return_type=dict,
     89                  tag='BinaryShortRangeOrderObserver')
     91 self._structure = structure
---> 93 self._cluster_space = ClusterSpace(
     94     structure=cluster_space.primitive_structure,
     95     cutoffs=[radius],
     96     chemical_symbols=cluster_space.chemical_symbols)
     97 self._cluster_count_observer = ClusterCountObserver(
     98     cluster_space=self._cluster_space, structure=structure,
     99     interval=interval)
    101 self._sublattices = self._cluster_space.get_sublattices(structure)

File ~/anaconda3/lib/python3.10/site-packages/icet/core/cluster_space.py:147, in ClusterSpace.__init__(self, structure, cutoffs, chemical_symbols, symprec, position_tolerance)
    144 self._config['fractional_position_tolerance'] = round(tol, -int(floor(log10(abs(tol)))))
    146 # set up orbit list
--> 147 self._orbit_list = OrbitList(
    148     structure=occupied_primitive,
    149     cutoffs=self._cutoffs,
    150     chemical_symbols=self._primitive_chemical_symbols,
    151     symprec=self.symprec,
    152     position_tolerance=self.position_tolerance,
    153     fractional_position_tolerance=self.fractional_position_tolerance)
    154 self._orbit_list.remove_orbits_with_inactive_sites()
    156 # call (base) C++ constructor

File ~/anaconda3/lib/python3.10/site-packages/icet/core/orbit_list.py:83, in OrbitList.__init__(self, structure, cutoffs, chemical_symbols, symprec, position_tolerance, fractional_position_tolerance)
     80 logger.info('Done getting neighbor lists.')
     82 # Transform matrix_of_equivalent_positions to be in lattice site format
---> 83 pm_lattice_sites = _get_lattice_site_matrix_of_equivalent_positions(
     84     structure=prim_structure,
     85     matrix_of_equivalent_positions=matrix_of_equivalent_positions,
     86     fractional_position_tolerance=fractional_position_tolerance,
     87     prune=True)
     89 logger.info('Transformation of matrix of equivalent positions'
     90             ' to lattice neighbor format completed.')
     92 _OrbitList.__init__(self,
     93                     structure=prim_structure,
     94                     matrix_of_equivalent_sites=pm_lattice_sites,
     95                     neighbor_lists=neighbor_lists,
     96                     position_tolerance=position_tolerance)

File ~/anaconda3/lib/python3.10/site-packages/icet/core/matrix_of_equivalent_positions.py:163, in _get_lattice_site_matrix_of_equivalent_positions(structure, matrix_of_equivalent_positions, fractional_position_tolerance, prune)
    161 lattice_sites = []
    162 if np.all(structure.pbc):
--> 163     lattice_sites = structure.find_lattice_sites_by_positions(
    164         positions=positions, fractional_position_tolerance=fractional_position_tolerance)
    165 else:
    166     raise ValueError('Input structure must have periodic boundary conditions.')

File ~/anaconda3/lib/python3.10/site-packages/icet/core/structure.py:76, in Structure.find_lattice_sites_by_positions(self, positions, fractional_position_tolerance)
     74 lattice_sites = []
     75 for position in positions:
---> 76     lattice_sites.append(self.find_lattice_site_by_position(
     77         position=position,
     78         fractional_position_tolerance=fractional_position_tolerance))
     79 return lattice_sites

RuntimeError: Failed to find site by position (findLatticeSiteByPosition).
Try increasing symprec or position_tolerance.
position: 2.8429 6.56539 2.35761
scaled position: 2.5 0.5 -2.5
fractional position tolerance: 2e-06

Can you try many different values of the radius, specifially many smaller values, and see if this works?

I tried all numbers from 1 to 8 and 8.09 (my pair-cutoff) the Error stays the same

I attached the notebook I want to use this in; I mean, maybe my error is somewhere earlier and it just comes up at this point

plot_order_parameter.ipynb (19.6 KB)

Its confusing because what is failing is setting up a cluster space inside the SRO class , but presumably you have already done this sucessfully.
Does it work to initialize the SRO object with the ideal primitive cell? or it still fails?

Still the same Error. Would It help if I send you the CE and one of the files I wanna analyze?

Yea feel free to upload here a structure file, and code, a minimum working example, for building the ClusterSpace and the SRO that reproduces the error.

(I dont think the CE is needed here for the SRO error)

So this is an Example of the files I wanna analyze, the Cluster Expansion I used for the simulation and want to use for the Observer and the Notebook, I tried to use the Binary Observer in.
We made an error in the Size of the simulation cell tho, since the Atom will count itself as influencing neighbour. If that creates the Error we already know where it comes from, if not the binary observer would be interesting for future simulations; that don’t have flaws in the setup. :sweat_smile:

Mh the this should have been a link to a folder; well again

The notebook with the 2 additional files doesnt run on its own.

If you want help debugging please make a minimum, as small as possible, script that reproduces the error and attach all needed files to run the script.

Sorry, I haven’t answered so long. I used a Warren-Cowley-Parameter now since one of my colleagues was already using them without issues.
If you want to reproduce the Error to improve your programs I made a folder with the files needed. Everything tested to run stand alone this time. :sweat_smile: