Ejemplo n.º 1
0
def observables(MCcalc, outputfi):
    energy = MCcalc.energy
    nup = MCcalc.config.count("OH", 0)[0]
    ndown = MCcalc.config.count("OH", 1)[0]
    tot_pol = np.abs(nup - ndown) / 6
    grid = grid_1D(0.02, 0.02, 5.0)
    g_r_dat = g_r(MCcalc.config.structure, "O", "H", grid)
    # energy2 = energy**2.0
    # xparam = MCcalc.model.xparam(MCcalc.config)
    outputfi.write("\t".join([
        str(observable)
        for observable in [MCcalc.kT, energy, nup, ndown, tot_pol]
    ]) + "\n")
    outputfi.flush()
    scalar_obs = [MCcalc.kT, energy, nup, ndown, tot_pol]
    return obs_encode(scalar_obs, g_r_dat)
Ejemplo n.º 2
0
################### model setup ###############################
# baseinput = VaspInput.from_directory("baseinput")
energy_calculator = vasp_runner(
    base_input_dir="./baseinput",
    path_to_vasp="/home/i0009/i000900/src/vasp.5.3/vasp.spawnready.gamma",
    nprocs_per_vasp=nprocs_per_replica,
    comm=MPI.COMM_SELF,
    perturb=0.1,
)
# energy_calculator = test_runner()
model = dft_latgas(energy_calculator, save_history=True)
##############################################################

################### RXMC calculation #########################
kTs = kB * np.array([kTstart * kTstep**i for i in range(nreplicas)])
grid = grid_1D(dr, dr, maxr)
RXcalc = TemperatureRX_MPI(comm, CanonicalMonteCarlo, model, configs, kTs)

obs = RXcalc.run(eqsteps,
                 RXtrial_frequency,
                 sample_frequency,
                 observfunc=observables,
                 subdirs=True)
# RXcalc.reload()
obs = RXcalc.run(nsteps,
                 RXtrial_frequency,
                 sample_frequency,
                 observfunc=observables,
                 subdirs=True)

if comm.Get_rank() == 0:
Ejemplo n.º 3
0
import random as rand
import sys

from py_mc.mc import CanonicalMonteCarlo, grid_1D
from model_setup import *


if __name__ == "__main__":
    L = 1.0
    rdisc = 1.0 / 14.0
    Ndisc = 20
    dr = 0.01
    maxstep = rdisc / 2
    kT = 1

    grid = grid_1D(dr, dr, L / 2.0)
    config = HC_2D_config(L, Ndisc, rdisc)
    model = HC_2D(maxstep)
    config.prepare_ordered()
    print(config.coors)
    print(g_r(config, grid))
    calc = CanonicalMonteCarlo(model, kT, config, grid=grid)
    plot_fig(calc, 10000)
    # calc.run(10000, observefunc=observables)
    # print(config.coors)

    """calc = Canonical
    
    J = -1.0
    kT = abs(J) * 1.0
    size = 10