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

nexus tile may duplicate atom position #1408

Closed
Paul-St-Young opened this issue Mar 1, 2019 · 5 comments
Closed

nexus tile may duplicate atom position #1408

Paul-St-Young opened this issue Mar 1, 2019 · 5 comments
Assignees

Comments

@Paul-St-Young
Copy link
Contributor

I have attached an example where nexus.Structure::tile produced a supercell with two atoms on top of each other. @jtkrogel do you see an easy fix for this?

I found a workaround by adding "use_ase" flag to tile(). May I PR this as a feature?

diff --git a/nexus/lib/structure.py b/nexus/lib/structure.py
index a374ca728..9f2d6143d 100755
--- a/nexus/lib/structure.py
+++ b/nexus/lib/structure.py
@@ -2947,6 +2947,7 @@ class Structure(Sobj):
 
 
     def tile(self,*td,**kwargs):
+        use_ase            = kwargs.pop('use_ase',False)
         in_place           = kwargs.pop('in_place',False)
         magnetic_order     = kwargs.pop('magnetic_order',None)
         magnetic_primitive = kwargs.pop('magnetic_primitive',True)
@@ -2979,8 +2980,18 @@ class Structure(Sobj):
 
         self.recenter()
 
+        # get atomic positions "pos"
+        if use_ase:
+          from ase import Atoms
+          from ase.build import make_supercell
+          atext = ''.join(self.elem)
+          pbc = [True if b == 'p' else False for b in self.bconds]
+          a0 = Atoms(atext, cell=self.axes, positions=self.pos, pbc=pbc)
+          a1 = make_supercell(a0, tilematrix)
+          pos = a1.get_positions()
+        else:
+          pos  = self.tile_points(self.pos,self.axes,tilematrix,tilevector)
         elem = array(ncells*list(self.elem))
-        pos  = self.tile_points(self.pos,self.axes,tilematrix,tilevector)
         axes = dot(tilematrix,self.axes)
 
         center   = axes.sum(0)/2

tile.zip

@prckent
Copy link
Contributor

prckent commented Mar 5, 2019

Better to fix the bug in tile. This should never happen.

@jtkrogel
Copy link
Contributor

jtkrogel commented Mar 8, 2019

I'm looking at this now. Apparently performing the shear operations to obtain the diagonal tiling can depend on the order in which you perform them. I will explore whether an alternative based on row reduction and pivoting would do the right thing.

@jtkrogel
Copy link
Contributor

@Paul-St-Young, please see #1432. Can you confirm that the fix works for you?

@Paul-St-Young
Copy link
Contributor Author

Yes, I can confirm the problem is fixed. Please go ahead and close this issue once #1432 is merged.
Thanks!

@jtkrogel
Copy link
Contributor

Resolved by #1432

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

No branches or pull requests

3 participants