Two Surface Object ExportΒΆ
The Sub-surface Translation example surface.
In this case, two objects are created which are then colored separately in Blender.
import numpy as np
import s3dlib.surface as s3d
#.. Two Surface Object Export
atomPos = {}
atomPos['Chloride'] = [
[ 1, 1, 1], [-1,-1, 1], [-1, 1, 1], [ 1,-1, 1] ,
[ 1, 1,-1], [-1,-1,-1], [-1, 1,-1], [ 1,-1,-1] ,
[ 1, 0, 0], [ 0, 1, 0], [-1, 0, 0], [ 0,-1, 0] , [ 0, 0, 1], [ 0, 0,-1] ]
atomPos['Sodium'] = [
[ 1, 0, 1], [-1, 0, 1], [ 0, 1, 1], [ 0,-1, 1] ,
[ 1, 1, 0], [-1,-1, 0], [-1, 1, 0], [ 1,-1, 0] , [ 0, 0, 0] ,
[ 1, 0,-1], [-1, 0,-1], [ 0, 1,-1], [ 0,-1,-1] ]
rez = 3
sz = 0.67
cells = { 'Chloride':None, 'Sodium':None }
for elemName, elemPos in atomPos.items() :
unitCell = None
for pos in elemPos :
atom = s3d.SphericalSurface(rez)
atom.transform(scale=[sz,sz,sz] , translate=pos)
if unitCell is None : unitCell = atom
else : unitCell += atom
sz = 1.0 - sz
cells[elemName] = unitCell
s3d.save_surfgeom_to_obj('obj_files/cl_cell.obj',cells['Chloride'])
s3d.save_surfgeom_to_obj('obj_files/na_cell.obj',cells['Sodium'])