def energy_aex(dA): aex_xc = prev = 0.0 n = int(w.arep[0,0]/dA + 0.5) w.cold_start = 1 for i in range(n): w.arep[0,0] = dA * (i + 1.0) w.dpd_potential() w.hnc_solve() curr = w.uex_xc / w.arep[0,0] aex_xc = aex_xc + 0.5*dA*(prev + curr) prev = curr return w.uex_mf + aex_xc
def energy_aex(dA): aex_xc = prev = 0.0 n = int(w.arep[0, 0] / dA + 0.5) w.cold_start = 1 for i in range(n): w.arep[0, 0] = dA * (i + 1.0) w.dpd_potential() w.hnc_solve() curr = w.uex_xc / w.arep[0, 0] aex_xc = aex_xc + 0.5 * dA * (prev + curr) prev = curr return w.uex_mf + aex_xc
w.ncomp = 2 # two components w.initialise() w.rho[0] = 3.0 w.rho[1] = 0.0 # zero density (still works!) # Warm up HNC by ramping the repulsion amplitude Amin = 25.0 Amax = 106.5 npt = 50 for i in range(npt): A = Amin + (Amax-Amin)*i/(npt-1.0) w.arep[0,0] = w.arep[0,1] = w.arep[1,1] = A w.dpd_potential(1) w.hnc_solve() print("%f\t%f\t%f\t%g" % (A, w.muex[0], w.muex[1], w.error)) # Now ramp the extra repulsion amplitude dAmin = -5.0 dAmax = 20.0 npt = 11 x = [0.0 for i in range(npt)] y = [0.0 for i in range(npt)] for i in range(npt): x[i] = dA = dAmin + (dAmax-dAmin)*i/(npt-1.0) w.arep[0,1] = A + dA
w.ng = 4096 w.ncomp = 3 w.initialise() w.sigma = 0.5 w.lb = 20.0 w.arep[:, :] = 25.0 w.arep[0, 1] = 30.0 w.arep[0, 2] = 27.0 w.arep[1, 2] = 20.0 w.z[0] = 1 w.z[1] = -1 w.dpd_potential() rho = 3.0 xc = 0.2 w.rho[0] = 0.5 * rho * xc w.rho[1] = 0.5 * rho * xc w.rho[2] = rho * (1 - xc) w.write_params() w.verbose = True w.hnc_solve() w.write_thermodynamics() # density-density structure factor
w.sigma = args.sigma if (args.R > 0): w.rgroot = args.R else: w.rgroot = args.sigma * m.sqrt(7.5) w.rc = args.rc w.arep[:,:] = args.A w.z[0] = args.z1 w.z[1] = args.z2 # potential type = 4 (exact), or potential type = 5 (approximate) with # beta = 1/lambda, or beta=5/(8lambda) if args.type < 4: w.dpd_potential(args.type) else: if args.case == 1: w.dpd_potential(w.dpd_slater_exact_charges) else: if args.case == 2: w.beta = 5 / (8*w.lbda) else: w.beta = 1 / w.lbda w.dpd_potential(w.dpd_slater_approx_charges) n = args.npt off = -2 eps = 1e-20 plt.figure(1)
# integrating the chemical potential along an isotherm. def mu_aex(drho): aex = prev = 0.0 n = int(w.rho[0]/drho + 0.5) w.cold_start = 1 for i in range(n): w.rho[0] = drho * (i + 1.0) w.hnc_solve() aex = aex + 0.5*drho*(prev + w.muex[0]) prev = w.muex[0] return aex w.initialise() w.arep[0,0] = A = 25.0 w.dpd_potential() w.rho[0] = rho = 3.0 w.hnc_solve() w.write_thermodynamics() print('SunlightHNC v%s' % str(w.version, 'utf-8').strip()) print('\n*** Example 6.1 ***\n') print('rho =', rho, ' A =', A) print('pressure =', w.press) print('energy density =', w.uex) # plt.xkcd() plt.figure(1) # This will be g(r)
# The calculation here solves rhoz = z1^2*rho1 + z2^2*rho2, z1*rho1 + z2*rho2 = 0 w.rho[0] = args.rhoz / (args.z1 * (args.z1 - args.z2)) w.rho[1] = args.rhoz / (args.z2 * (args.z2 - args.z1)) if (w.ncomp > 2): w.rho[2] = args.rho - w.rho[0] - w.rho[1] # potential type = 4 (exact), or potential type = 5 (approximate) with # beta = 1/lambda, or beta=5/(8lambda) --- warm up in lb if requested for i in range(args.nwarm): w.lb = (i + 1.0) / args.nwarm * args.lb if args.type < 4: w.dpd_potential(args.type) else: if args.case == 1: w.dpd_potential(w.dpd_slater_exact_charges) else: if args.case == 2: w.beta = 5 / (8 * w.lbda) else: w.beta = 1 / w.lbda w.dpd_potential(w.dpd_slater_approx_charges) if w.verbose: w.write_params() if (args.rpa or args.exp): w.rpa_solve() else: