Пример #1
0
      print "Energy scale of Lennard Jones Potential in kT units:", solver.getEpsilonInkTUnits()
      #Initialize HMSA with some (random) start alpha
      solver.doHMSAclosure(1.0)
  
  else:
      #Yukawa possible with RY: With negative K (attractive besides HS) convergence may be reached for exp shift only (real HS-Yukawa)
      #positive (repulsive as HS) K converges for fully shifted potential (1/r included)
      solver.setPotentialByName('Yukawa', 1.0, -1.0, True) #lamda in SASfit is different; K = 0.1 is default in SASfit
      print "Energy scale of Yukawa HS Potential in kT units:", solver.getInteractionStrengthInKTunits()
      print "Length scale of Yukawa HS Potential in sigma units:", solver.getShieldingConstantInSigmaUnits()
      #Initialize RY with some (random) start alpha
      solver.doRYclosure(1.0)

  
  solver.setVolumeDensity(0.3)
  print "Volume density of liquid:", solver.getVolumeDensity()
  
  print "start solving for optimal closure alpha...."
  
  #Should we minimize cost functional or find a root?
  doUseMinimizer = False
  doSearchIndependentPlot = False
  #Save iterated points in alpha space as dict to plot later
  finderFunctionGraph = {}
  
  if doUseMinimizer:
      #Ein Minimum macht noch keine Nullstelle, minimierungs algorithmen
      #kommen aber (auch) mit doppelten (mehrfachen) Nullstellen klar. *Falls* eine Nullstelle vorliegt,
      #ist sie in jedem Fall auch ein Minimum der quadrierten funktion (bei mehreren Nullstellen kein globales Minimum)
      alpha_opt = optimize.minimize(finderFunctionForAlpha, alpha_initial, args=(solver, finderFunctionGraph, doUseMinimizer,))
      print "optimal alpha according minimizer:", alpha_opt.x[0]
Пример #2
0
    else:
        #Yukawa possible with RY: With negative K (attractive besides HS) convergence may be reached for exp shift only (real HS-Yukawa)
        #positive (repulsive as HS) K converges for fully shifted potential (1/r included)
        solver.setPotentialByName(
            'Yukawa', 1.0, -1.0,
            True)  #lamda in SASfit is different; K = 0.1 is default in SASfit
        print "Energy scale of Yukawa HS Potential in kT units:", solver.getInteractionStrengthInKTunits(
        )
        print "Length scale of Yukawa HS Potential in sigma units:", solver.getShieldingConstantInSigmaUnits(
        )
        #Initialize RY with some (random) start alpha
        solver.doRYclosure(1.0)

    solver.setVolumeDensity(0.3)
    print "Volume density of liquid:", solver.getVolumeDensity()

    print "start solving for optimal closure alpha...."

    #Should we minimize cost functional or find a root?
    doUseMinimizer = False
    doSearchIndependentPlot = False
    #Save iterated points in alpha space as dict to plot later
    finderFunctionGraph = {}

    if doUseMinimizer:
        #Ein Minimum macht noch keine Nullstelle, minimierungs algorithmen
        #kommen aber (auch) mit doppelten (mehrfachen) Nullstellen klar. *Falls* eine Nullstelle vorliegt,
        #ist sie in jedem Fall auch ein Minimum der quadrierten funktion (bei mehreren Nullstellen kein globales Minimum)
        alpha_opt = optimize.minimize(finderFunctionForAlpha,
                                      alpha_initial,