示例#1
0
def main():
  
  trajFile, outFile, nSteps = getArgs(argv)

  nAve = 1
  circ = None
  frames = []
  with open(trajFile,'r') as inp:
    for n in range(nSteps):
      # How should block averaging of interfaces be done?
      # t, atoms = combineFrames(inp,nAve)
      # t, atoms = readFrame(inp)
      t, box, atoms = readTrj(inp)

      # remove vaporized chains by uncommenting last two mask conditions
      # mask = (atoms[:,0] == 1) # & (atoms[:,3] < 20) & (abs(atoms[:,2]) < 60)
      # atoms = atoms[mask][:,1:]
      mask = (atoms[:,1] == 1)
      atoms = atoms[mask][:,2:]
      atoms = atoms * (box[:,1] - box[:,0]) + box[:,0]
      # Find the center of mass in the xy direction and center droplet
      atoms, center = centerAtoms(atoms)

      # # make box
      # box = np.array([atoms.min(0)-0.01,atoms.max(0)+0.01]).T
      # box[1,:] += [-7,7]
      atoms[:,2] -= box[2,0]
      box[2,:] -= box[2,0]
      box[2,1] += 0.10

      # find interfacial atoms
      print t
      interface = findCylinderInterface(atoms, box)
      # pyplot.show()
      # Calculate the contact angle
      if not ((n+1) % nAve):
        try:
          angle, z0, R = contactAngle(interface[(interface[:,1] < 30) & 
                                                (abs(interface[:,0]) < 100)], box)
        except RuntimeError:
          print 'No interface'
          circ = None
        except IndexError:
          print 'Empty interface'
        else:
          # pyplot.plot(interface[:,0],interface[:,1],'o')
          circ = pyplot.Circle((0,z0), radius=R, fill=False)
          frames.append([t*0.002,angle,center])

    #       plotInterface(atoms,box,interface,circ,(t,angle))
    #   pyplot.savefig('test.png')
    #   pyplot.show()

    plotAngle(frames)
    pyplot.savefig('full.png')
    # pyplot.show()
    writeData(outFile,frames)
 
    print 'Finished analyzing trajectory'
def main():
  
  # Command line args processing
  trajFile, outFile, nFrames, nInsert, nSlices = getArgs(argv)
  
  outFile = '%s_%d' % (outFile, nInsert)

  # params = (a,b,r_cut,nAtomsPerPart,nPart)
  params = (25*0.5, 50*0.5, RC, 4684, 54)

  with open('density_'+outFile, 'w') as otp:
    otp.write('# Density profiles\n')
  with open('height_'+outFile, 'w') as otp:
    otp.write('# height profiles at two cut-offs\n')

  with open(trajFile,'r') as inp:
    for n in range(nFrames):
      # read data and separate by atomtypes
      time, box, frame = readTrj(inp)
      frame = frame[frame[:,0].argsort()]
      particles = frame[frame[:,1] >= 3][:,2:]
      polymers = frame[frame[:,1] == 1][:,4]
      pmin = polymers.min()

      cutOff = 0.85
      density, height85, porosity = findHeight(particles, box, nInsert, nSlices, params, polymers, cutOff)
      cutOff = 0.99
      height99 = integrateHeight(np.copy(density), cutOff)

      # rescale height
      dmax = density[-1,0]
      density[:,0] /= dmax
      height85 /= dmax
      height99 /= dmax
      # concatenate porosity and density???

      # output density and height values
      with open('density_'+outFile, 'a') as otp:
        header = '# time: %d\n#  z  density  porosity' % time
        np.savetxt(otp, density, fmt='%.5f', header=header, footer='\n', comments='')
      with open('height_'+outFile, 'a') as otp:
        np.savetxt(otp, [[time, height85, height99, density[0,0]]], fmt='%d %.5f %.5f %.5f',comments='')
      
  print 'Finished analyzing trajectory'