Ejemplo n.º 1
0
  
  print "start approaching target density", targetDensity
  while density < targetDensity:
    #deltaDensity /= decayFactor
    density += deltaDensity
    print "current density", density
    solver.setVolumeDensity(density)
    solver.solve()
    g = solver.getRDF()
    solver.setStartValue(g)
   
   
  #Direct calculation
  print "Directly calculating RDF for target density", targetDensity
  solver.setStartValue(np.zeros(solver.getNumberOfRadialSamplingPoints()) )
  solver.setVolumeDensity(targetDensity)
  solver.solve()
  g_direct = solver.getRDF()
  
  #Plot results
  r = np.arange(solver.getNumberOfRadialSamplingPoints() ).astype('float') + 1.0
  r *= solver.getDelta_r()/solver.getHardSphereRadius()

  pl.plot(r, g, label = 'RDF obtained by iterating over densities' );
  pl.plot(r, g_direct, label = 'RDF obtained directly' );
  pl.xlabel('r/sigma'); pl.ylabel('g(r)')
  pl.legend(loc = 'upper right')
      
  pl.show()

Ejemplo n.º 2
0
  #now GCE limit version
  solver.doEnforceGrandCanonicalZeroQlimit()
  #solver is in desired state.
  solver.solve()
  #Get GCE structure factor
  Sq_GCE = solver.getSq()
  print "reference Sq(0)", Sq_default[0]
  print "GCE Sq(0)", Sq_GCE[0]
  print "Analytical Sq(0)", (1.0 - volumeDensity)**4/(1.0 + 2.0*volumeDensity)**2
  
  #Even though the enforcement only affects one point in Fourier space,
  #the impact will be global, hence we plot the functions. (But real analyis must be done numerically)
  
  #Plot results
  Delta_r = solver.getDelta_r()
  numberOfRadialSamplingPoints = solver.getNumberOfRadialSamplingPoints()
  sigma = solver.getHardSphereRadius()
  Delta_q = np.pi/((numberOfRadialSamplingPoints + 1.0)*Delta_r)
  q = Delta_q*((np.arange(numberOfRadialSamplingPoints) + 1.0).astype('float'))
  
  plt.plot(np.arcsinh(q*sigma), Sq_default, label = 'Sq_default(q)');
  plt.xlabel('arcsinh(q*sigma)'); plt.ylabel('Sq_default(q)')

  plt.plot(np.arcsinh(q*sigma), Sq_GCE, label = 'Sq_GCE(q)');
  plt.xlabel('arcsinh(q*sigma)'); plt.ylabel('Sq_GCE(q)')

  plt.legend(loc = 'upper right')
      
  plt.show()

Ejemplo n.º 3
0
  #densityRange = np.asarray([0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5])
  

  densityRDFdictionary = {}
  
  #Start loop over densities and measure wall clock time
  t_start = time.time()
  
  for d in densityRange:
      s.setVolumeDensity(float(d))
      s.solve()
      g = s.getRDF()
      densityRDFdictionary[d] = g

  t_stop = time.time()
  
  #Print out benchmark
  print "time used for", densityRange.size, "density parameters:", t_stop - t_start, " sec" 
  print "time used for one OZ run:", (t_stop - t_start)/float(densityRange.size), "seconds"
  
  #Plot results
  r = np.arange(s.getNumberOfRadialSamplingPoints() ).astype('float') + 1.0
  r *= s.getDelta_r()/s.getHardSphereRadius()

  for densityKey in densityRDFdictionary:
      pl.plot(r, densityRDFdictionary[densityKey], label = 'RDF for d=' + str(densityKey));
      pl.xlabel('r/sigma'); pl.ylabel('g(r)')
      pl.legend(loc = 'upper right')
      
  pl.show()
Ejemplo n.º 4
0
    #solver is in desired state.
    solver.solve()
    #Get GCE structure factor
    Sq_GCE = solver.getSq()
    print "reference Sq(0)", Sq_default[0]
    print "GCE Sq(0)", Sq_GCE[0]
    print "Analytical Sq(0)", (1.0 - volumeDensity)**4 / (
        1.0 + 2.0 * volumeDensity)**2

    #Even though the enforcement only affects one point in Fourier space,
    #the impact will be global, hence we plot the functions. (But real analyis must be done numerically)

    #Plot results
    Delta_r = solver.getDelta_r()
    numberOfRadialSamplingPoints = solver.getNumberOfRadialSamplingPoints()
    sigma = solver.getHardSphereRadius()
    Delta_q = np.pi / ((numberOfRadialSamplingPoints + 1.0) * Delta_r)
    q = Delta_q * (
        (np.arange(numberOfRadialSamplingPoints) + 1.0).astype('float'))

    plt.plot(np.arcsinh(q * sigma), Sq_default, label='Sq_default(q)')
    plt.xlabel('arcsinh(q*sigma)')
    plt.ylabel('Sq_default(q)')

    plt.plot(np.arcsinh(q * sigma), Sq_GCE, label='Sq_GCE(q)')
    plt.xlabel('arcsinh(q*sigma)')
    plt.ylabel('Sq_GCE(q)')

    plt.legend(loc='upper right')

    plt.show()