Ejemplo n.º 1
0
def test_md():
    import numpy as np
    import unittest

    from ase.units import Ry, Ha
    from ase.calculators.openmx import OpenMX
    from ase.io.trajectory import Trajectory
    from ase.optimize import QuasiNewton
    from ase.constraints import UnitCellFilter
    from ase.calculators.calculator import PropertyNotImplementedError
    from ase import Atoms
    """ Only OpenMX 3.8 or higher version pass this test"""

    bud = Atoms('CH4', np.array([
            [0.000000, 0.000000, 0.100000],
            [0.682793, 0.682793, 0.682793],
            [-0.682793, -0.682793, 0.68279],
            [-0.682793, 0.682793, -0.682793],
            [0.682793, -0.682793, -0.682793]]),
            cell=[10, 10, 10])

    calc = OpenMX(
        label='ch4',
        xc='GGA',
        energy_cutoff=300 * Ry,
        convergence=1e-4 * Ha,
        # Use 'C_PBE19' and 'H_PBE19' for version 3.9
        definition_of_atomic_species=[['C', 'C5.0-s1p1', 'C_PBE13'],
                                      ['H', 'H5.0-s1', 'H_PBE13']],
        kpts=(4, 4, 4),
        eigensolver='Band'
        )

    bud.set_calculator(calc)

    try:
        bud.get_stress()
    except PropertyNotImplementedError as err:
        raise unittest.SkipTest(err)

    traj = Trajectory('example.traj', 'w', bud)
    ucf = UnitCellFilter(bud, mask=[True, True, False, False, False, False])
    dyn = QuasiNewton(ucf)
    dyn.attach(traj.write)
    dyn.run(fmax=0.1)
    bud.get_potential_energy()
    # XXX maybe assert something?

    traj.close()
Ejemplo n.º 2
0
def read_openmx(filename=None, debug=False):
    from ase.calculators.openmx import OpenMX
    from ase import Atoms
    """
    Read results from typical OpenMX output files and returns the atom object
    In default mode, it reads every implementd properties we could get from
    the files. Unlike previous version, we read the information based on file.
    previous results will be eraised unless previous results are written in the
    next calculation results.

    Read the 'LABEL.log' file seems redundant. Because all the
    information should already be written in '.out' file. However, in the
    version 3.8.3, stress tensor are not written in the '.out' file. It only
    contained in the '.log' file. So... I implented reading '.log' file method
    """
    log_data = read_file(get_file_name('.log', filename), debug=debug)
    restart_data = read_file(get_file_name('.dat#', filename), debug=debug)
    dat_data = read_file(get_file_name('.dat', filename), debug=debug)
    out_data = read_file(get_file_name('.out', filename), debug=debug)
    scfout_data = read_scfout_file(get_file_name('.scfout', filename))
    band_data = read_band_file(get_file_name('.Band', filename))
    # dos_data = read_dos_file(get_file_name('.Dos.val', filename))
    """
    First, we get every data we could get from the all results files. And then,
    reform the data to fit to data structure of Atom object. While doing this,
    Fix the unit to ASE format.
    """
    parameters = get_parameters(out_data=out_data,
                                log_data=log_data,
                                restart_data=restart_data,
                                dat_data=dat_data,
                                scfout_data=scfout_data,
                                band_data=band_data)
    atomic_formula = get_atomic_formula(out_data=out_data,
                                        log_data=log_data,
                                        restart_data=restart_data,
                                        scfout_data=scfout_data,
                                        dat_data=dat_data)
    results = get_results(out_data=out_data,
                          log_data=log_data,
                          restart_data=restart_data,
                          scfout_data=scfout_data,
                          dat_data=dat_data,
                          band_data=band_data)

    atoms = Atoms(**atomic_formula)
    atoms.set_calculator(OpenMX(**parameters))
    atoms.calc.results = results
    return atoms
Ejemplo n.º 3
0
 def calc(self, **kwargs):
     from ase.calculators.openmx import OpenMX
     return OpenMX(command=self.executable,
                   data_path=str(self.data_path),
                   **kwargs)
Ejemplo n.º 4
0
from ase import Atoms
from ase.test.testsuite import NotAvailable
import numpy as np
""" Only OpenMX 3.8 or higher version pass this test"""

bud = Atoms('CH4',
            np.array([[0.000000, 0.000000, 0.100000],
                      [0.682793, 0.682793, 0.682793],
                      [-0.682793, -0.682793, 0.68279],
                      [-0.682793, 0.682793, -0.682793],
                      [0.682793, -0.682793, -0.682793]]),
            cell=[10, 10, 10])

calc = OpenMX(label='ch4',
              xc='GGA',
              energy_cutoff=300 * Ry,
              definition_of_atomic_species=[['C', 'C5.0-s1p1', 'C_PBE13'],
                                            ['H', 'H5.0-s1', 'H_PBE13']])

bud.set_calculator(calc)

try:
    e = bud.get_stress()
except PropertyNotImplementedError as err:
    raise NotAvailable(err)

traj = Trajectory('example.traj', 'w', bud)
ucf = UnitCellFilter(bud, mask=[True, True, False, False, False, False])
dyn = QuasiNewton(ucf)
dyn.attach(traj.write)
dyn.run(fmax=0.02)