In [1]:
import numpy as np
import pyfaunus as mc


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-623238544dc6> in <module>()
      1 import numpy as np
----> 2 import pyfaunus as mc

ImportError: /home/max/miniconda2/lib/python2.7/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./pyfaunus.so)

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()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-f85b67b3de15> in <module>()
----> 1 jsoninput = mc.InputMap('../src/examples/minimal.json')
      2 space = mc.Space(jsoninput)
      3 print(space.info())
      4 print 'system volume = ',space.geo.getVolume()

NameError: name 'mc' is not defined

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()


salt
100
[0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L]

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)


position of first atom = [ 24.6440651   24.82306628  23.38474685]
total charge           = 0.0

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)


center of mass =  [  5.85548473  -2.22391004  21.22989251]

In [ ]: