Skip to content

Commit 11cfe3b

Browse files
committed
Added a hack that visualizes the a simple cubic unit cell when axis is clicked.
1 parent efa82f8 commit 11cfe3b

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

exatomic/algorithms/neighbors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def sorter(group, source_atom_idxs):
174174
nearest['frame'] = nearest['frame'].astype(int)
175175
nearest['molecule'] = nearest['molecule'].astype(int)
176176
dct['nearest'].append(nearest)
177+
return uu
177178
for nn in sizes:
178179
atm = []
179180
for j, fdx in enumerate(nearest['frame'].unique()):

exatomic/widgets/traits.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ def two_traits(uni):
118118

119119
def frame_traits(uni):
120120
"""Get frame table traits."""
121-
if not hasattr(uni, 'frame'): return {}
122-
# TODO :: Implement me!!
121+
# ASSUME SIMPLE CUBIC CELL this is a hack for now.
122+
if 'xi' in uni.frame.columns:
123+
return {'frame__a': uni.frame['xi'].max()}
123124
return {}
124125

125126
def tensor_traits(uni):
@@ -133,6 +134,8 @@ def uni_traits(uni, atomcolors=None, atomradii=None, atomlabels=None):
133134
"""Get Universe traits."""
134135
unargs = {}
135136
fields, tensors = [], None
137+
if hasattr(uni, 'frame'):
138+
unargs.update(frame_traits(uni))
136139
if hasattr(uni, 'atom'):
137140
unargs.update(atom_traits(uni.atom, atomcolors, atomradii, atomlabels))
138141
if hasattr(uni, 'atom_two'):

exatomic/widgets/widget_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class UniverseScene(ExatomicScene):
198198
# Tensor traits
199199
tensor_d = Dict().tag(sync=True)
200200
# Frame traits
201-
201+
frame__a = Float(0.0).tag(sync=True)
202202
# Tensor traits
203203
tens = Bool(False).tag(sync=True)
204204
tensor_d = Dict().tag(sync=True)

js/src/appthree.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,16 @@ class App3D {
518518
meshes.push(mesh);
519519
};
520520
};
521+
// Hack to also add unit cell if present
522+
var a = this.view.model.get("frame__a");
523+
if (a !== undefined) {
524+
var _box = new THREE.BoxBufferGeometry(a, a, a);
525+
var _edg = new THREE.EdgesGeometry(_box);
526+
var _mat = new THREE.LineBasicMaterial({color: 0x808080});
527+
var _lin = new THREE.LineSegments(_edg, _mat);
528+
_lin.position.set(a/2, a/2, a/2);
529+
meshes.push(_lin);
530+
}
521531
return meshes;
522532
};
523533

js/src/widgets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ var UniverseSceneView = base.ExatomicSceneView.extend({
154154
},
155155

156156
add_axis: function() {
157+
// Additionally adds the unit cell
157158
this.app3d.clear_meshes("generic");
158159
if (this.model.get("axis")) {
159160
this.app3d.meshes["generic"] = this.app3d.add_unit_axis(

0 commit comments

Comments
 (0)