In [1]:
import numpy as np
import pyfaunus as mc
Create Space from an already existing .json
input file:
In [2]:
jsoninput = mc.InputMap('../src/examples/minimal.json')
space = mc.Space(jsoninput)
print(space.info())
print 'system volume = ',space.geo.getVolume()
Probe group information and get particle index:
In [3]:
groups = space.groupList()
for group in groups:
print group.name
print len(group)
print group.range()
Extract positions etc from a group
In [15]:
positions = [ np.array((space.p[i].x, space.p[i].y, space.p[i].z)) for i in groups[0].range()]
charges = [ space.p[i].charge for i in groups[0].range()]
print 'position of first atom =', positions[0]
print 'total charge =', sum(charges)
Calculate center of mass for a group
In [5]:
saltgroup = space.groupList()[0]
cm = mc.massCenter(space.geo, space.p, saltgroup)
print "center of mass = ", np.array(cm)
In [ ]: