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


 ...............................
  Simulation Space and Geometry  
 *******************************
  Boundary                 Cuboid
  Volume                   125000 ų = 125 nm³ = 1.25e-22 liters
  Sidelengths              50 50 50 (Å)
  Scale directions         XYZ
  Number of particles      100
  Electroneutrality        Yes 0
  System sanity check      Passed
  Number of molecule types 1
  Groups:
    1     [0-99]           salt        N/V = 0.0008 Å⁻³ = 1328.43 mM  

system volume =  125000.0

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 [4]:
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.82306628  23.38474685  11.29194816]
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 =  [-23.71497592   0.41635248   7.08268208]

This part is purely experimental and merely to illustrate how the interface could look like


In [ ]:
spc = mc.Space(...)
spc.addAtomType(name='OW', weight=18, charge=-0.3, epsilon=0.03, sigma=0.3)
spc.addMoleculeType(name='water', atoms=['HW HW OW'], rigid=True)
spc.addMoleculeType(name='salt', atoms=['Na Cl'], atomic=True)
spc.addMolecules(type='water', N=100)

potential = mc.potentials.Coulomb(epsr=80, cutoff=10) +
    mc.potentials.LennardJones(combinationrule='LB')