예제 #1
0
    # RXcalc.reload()
    obs = RXcalc.run(
        nsteps=10,
        RXtrial_frequency=2,
        sample_frequency=1,
        observfunc=observables,
        subdirs=True,
    )
    if worldrank == 0:
        for i in range(len(kTs)):
            with open("T" + str(i) + ".dat", "w") as f:
                f.write("\n".join(
                    [str(obs[i, j]) for j in range(len(obs[i, :]))]))

    for i in range(9):
        RXcalc.reload()
        obs += RXcalc.run(
            nsteps=10,
            RXtrial_frequency=2,
            sample_frequency=1,
            observfunc=observables,
            subdirs=True,
        )
        obs_write = obs / float(i + 2)
        if worldrank == 0:
            for i in range(len(kTs)):
                with open("T" + str(i) + ".dat", "w") as f:
                    f.write("\n".join([
                        str(obs_write[i, j])
                        for j in range(len(obs_write[i, :]))
                    ]))
예제 #2
0
파일: main.py 프로젝트: gmp007/abICS
def main():
    tomlfile = sys.argv[1] if len(sys.argv) > 1 else "input.toml"
    rxparams = RXParams.from_toml(tomlfile)
    nreplicas = rxparams.nreplicas
    nprocs_per_replica = rxparams.nprocs_per_replica

    kB = 8.6173e-5

    comm = RX_MPI_init(rxparams)

    # RXMC parameters
    # specify temperatures for each replica, number of steps, etc.
    kTstart = rxparams.kTstart
    kTend = rxparams.kTend
    kTs = kB * np.linspace(kTstart, kTend, nreplicas)

    # Set Lreload to True when restarting
    Lreload = rxparams.reload

    nsteps = rxparams.nsteps
    RXtrial_frequency = rxparams.RXtrial_frequency
    sample_frequency = rxparams.sample_frequency
    print_frequency = rxparams.print_frequency

    dftparams = DFTParams.from_toml(tomlfile)

    if dftparams.solver == 'vasp':
        solver = VASPSolver(dftparams.path)
    elif dftparams.solver == 'qe':
        solver = QESolver(dftparams.path)
    else:
        print('unknown solver: {}'.format(dftparams.solver))
        sys.exit(1)

    # model setup
    # we first choose a "model" defining how to perform energy calculations and trial steps
    # on the "configuration" defined below
    energy_calculator = runner(base_input_dir=dftparams.base_input_dir,
                               Solver=solver,
                               nprocs_per_solver=nprocs_per_replica,
                               comm=MPI.COMM_SELF,
                               perturb=dftparams.perturb,
                               solver_run_scheme=dftparams.solver_run_scheme)
    model = dft_latgas(energy_calculator, save_history=False)

    # defect sublattice setup

    configparams = DFTConfigParams.from_toml(tomlfile)

    spinel_config = defect_config(configparams)

    configs = []
    for i in range(nreplicas):
        configs.append(copy.deepcopy(spinel_config))

    obsparams = ObserverParams.from_toml(tomlfile)

    # RXMC calculation
    RXcalc = TemperatureRX_MPI(comm, CanonicalMonteCarlo, model, configs, kTs)
    if Lreload:
        RXcalc.reload()
    obs = RXcalc.run(
        nsteps,
        RXtrial_frequency,
        sample_frequency,
        print_frequency,
        observer=default_observer(comm, Lreload),
        subdirs=True,
    )

    if comm.Get_rank() == 0:
        print(obs)