if doLennardJonesExample: #LJ possible but with HMSA solver.setPotentialByName('LennardJones', 0.1) #epsilon/kT = 0.1 is default in SASfit 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
solver = ScipyAndersonOZsolver(port = 0) solver.setPotentialByName('HardSphere') solver.setVolumeDensity(0.4) #Default is PY print "PY closure.." solver.solve() closureRDFdictionary['PY'] = solver.getRDF() print "HNC closure.." solver.doHNCclosure() solver.solve() closureRDFdictionary['HNC'] = solver.getRDF() print "RY closure, alpha -> 0.." solver.doRYclosure(alpha=0.0001) #Not exactly zero... solver.solve() closureRDFdictionary['RY alpha -> 0'] = solver.getRDF() print "RY closure, alpha -> inf.." solver.doRYclosure(alpha=100000.0) solver.solve() closureRDFdictionary['RY alpha -> inf'] = solver.getRDF() print "RY closure, alpha = 3.0" #last but not least a alpha in between solver.doRYclosure(alpha=3.0) solver.solve() closureRDFdictionary['RY alpha=3.0'] = solver.getRDF()
solver = ScipyAndersonOZsolver(port=0) solver.setPotentialByName('HardSphere') solver.setVolumeDensity(0.4) #Default is PY print "PY closure.." solver.solve() closureRDFdictionary['PY'] = solver.getRDF() print "HNC closure.." solver.doHNCclosure() solver.solve() closureRDFdictionary['HNC'] = solver.getRDF() print "RY closure, alpha -> 0.." solver.doRYclosure(alpha=0.0001) #Not exactly zero... solver.solve() closureRDFdictionary['RY alpha -> 0'] = solver.getRDF() print "RY closure, alpha -> inf.." solver.doRYclosure(alpha=100000.0) solver.solve() closureRDFdictionary['RY alpha -> inf'] = solver.getRDF() print "RY closure, alpha = 3.0" #last but not least a alpha in between solver.doRYclosure(alpha=3.0) solver.solve() closureRDFdictionary['RY alpha=3.0'] = solver.getRDF() #Plot results
) #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,