Ejemplo n.º 1
0
def test_run_single_reaxff(db_test_app, get_structure,
                           pyrite_potential_reaxff_lowtol, data_regression):
    # type: (AiidaTestApp) -> None

    code = db_test_app.get_or_create_code("gulp.single")
    builder = code.get_builder()
    builder._update({
        "metadata": {
            "options": {
                "withmpi": False,
                "resources": {
                    "num_machines": 1,
                    "num_mpiprocs_per_machine": 1
                },
                "max_wallclock_seconds": 30,
            }
        }
    })
    builder.structure = get_structure("pyrite")
    builder.potential = pyrite_potential_reaxff_lowtol

    calc_node = run_get_node(builder).node

    db_test_app.check_calculation(calc_node, ["results"])

    result = recursive_round(calc_node.outputs.results.get_dict(), 6)
    for key in [
            "parser_version",
            "peak_dynamic_memory_mb",
            "opt_time_second",
            "total_time_second",
    ]:
        result.pop(key, None)
    data_regression.check(result)
Ejemplo n.º 2
0
def test_parse_failed_optimize(data_regression):
    # type: (AiidaTestApp) -> None
    with open_resource_text("gulp", "failed", "opt_step_limit.gout") as handle:
        data, exit_code = parse_file(handle, "test_class")

    result = recursive_round(data, 6)
    result.pop("parser_version")
    data_regression.check(result)

    assert exit_code == "ERROR_OPTIMISE_MAX_ATTEMPTS"
Ejemplo n.º 3
0
def test_parse_polymer_opt(data_regression):
    # type: (AiidaTestApp) -> None
    """ this is a surface calculation """
    with open_resource_text("gulp", "s2_polymer_opt", "main.gout") as handle:
        data, exit_code = parse_file(handle, "test_class")

    result = recursive_round(data, 6)
    result.pop("parser_version")
    data_regression.check(result)

    assert exit_code is None
Ejemplo n.º 4
0
def test_parse_non_primitive_opt(data_regression):
    # type: (AiidaTestApp) -> None
    with open_resource_text("gulp", "non_primitive_opt",
                            "main.gout") as handle:
        data, exit_code = parse_file(handle, "test_class")

    result = recursive_round(data, 6)
    result.pop("parser_version")
    data_regression.check(result)

    assert exit_code is None
Ejemplo n.º 5
0
def test_run_optimize_lj_with_symm(db_test_app, get_structure,
                                   pyrite_potential_lj, data_regression):
    # type: (AiidaTestApp) -> None
    from aiida.engine import run_get_node

    structure = get_structure("pyrite")
    symmetry = DataFactory("gulp.symmetry")(
        data=compute_symmetry_dict(structure, 0.01, None))
    parameters = db_test_app.get_data_node(
        "dict",
        dict={
            "minimize": {
                "style": "cg",
                "max_iterations": 100
            },
            "relax": {
                "type": "conp"
            },
        },
    )

    code = db_test_app.get_or_create_code("gulp.optimize")
    builder = code.get_builder()
    builder._update({
        "metadata": {
            "options": {
                "withmpi": False,
                "resources": {
                    "num_machines": 1,
                    "num_mpiprocs_per_machine": 1
                },
                "max_wallclock_seconds": 30,
            }
        }
    })
    builder.structure = structure
    builder.potential = pyrite_potential_lj
    builder.parameters = parameters
    builder.symmetry = symmetry

    calc_node = run_get_node(builder).node

    db_test_app.check_calculation(calc_node,
                                  ["results", "structure", "retrieved"])

    result = recursive_round(calc_node.outputs.results.get_dict(), 6)
    for key in [
            "parser_version",
            "peak_dynamic_memory_mb",
            "opt_time_second",
            "total_time_second",
    ]:
        result.pop(key, None)
    data_regression.check(result)
Ejemplo n.º 6
0
def test_run_reaxff_fes(db_test_app, get_structure, data_regression):
    """Test submitting a calculation."""
    code = db_test_app.get_or_create_code("gulp.fitting")
    builder = code.get_builder()
    builder.metadata = db_test_app.get_default_metadata()
    potential_cls = DataFactory("gulp.potential")
    pot_data = read_lammps_format(
        read_resource_text("gulp", "potentials",
                           "FeCrOSCH.reaxff").splitlines())
    pot_data = filter_by_species(pot_data, ["Fe core", "S core"])
    builder.settings = {"observables": {"energy": {}}}
    builder.potential = potential_cls(
        "reaxff",
        pot_data,
        fitting_data={
            "species": ["Fe core", "S core"],
            "global": ["reaxff0_boc1", "reaxff0_boc2"],
        },
    )
    builder.structures = {
        "pyrite": get_structure("pyrite"),
        "marcasite": get_structure("marcasite"),
        "zincblende": get_structure("zincblende"),
    }
    builder.observables = {
        "pyrite": Dict(dict={
            "energy": -1,
            "energy_units": "eV"
        }),
        "marcasite": Dict(dict={
            "energy": -1,
            "energy_units": "eV"
        }),
        "zincblende": Dict(dict={
            "energy": 1,
            "energy_units": "eV"
        }),
    }
    builder.metadata["options"]["allow_create_potential_fail"] = True

    calc_node = run_get_node(builder).node

    db_test_app.check_calculation(calc_node, ["results"])

    result = recursive_round(calc_node.outputs.results.get_dict(), 6)
    for key in [
            "parser_version",
            "peak_dynamic_memory_mb",
            "opt_time_second",
            "total_time_second",
    ]:
        result.pop(key, None)
    data_regression.check(result)
Ejemplo n.º 7
0
def test_parse_single_lj_pyrite(data_regression):
    # type: (AiidaTestApp) -> None
    with open_resource_text("gulp", "single_lj_pyrite", "main.gout") as handle:
        data, exit_code = parse_file(handle,
                                     "test_class",
                                     single_point_only=True)

    result = recursive_round(data, 6)
    result.pop("parser_version")
    data_regression.check(result)

    assert exit_code is None
Ejemplo n.º 8
0
def test_run_lj_fes(db_test_app, get_structure, data_regression):
    """Test running a calculation."""
    code = db_test_app.get_or_create_code("gulp.fitting")
    builder = code.get_builder()
    builder.metadata = db_test_app.get_default_metadata()
    potential_cls = DataFactory("gulp.potential")
    builder.potential = potential_cls(
        "lj",
        {
            "species": ["Fe core", "S core"],
            "2body": {
                "0-0": {
                    "lj_A": 1.0,
                    "lj_B": 1.0,
                    "lj_rmax": 12.0
                },
                "0-1": {
                    "lj_A": 1.0,
                    "lj_B": 1.0,
                    "lj_rmax": 12.0
                },
                "1-1": {
                    "lj_A": 1.0,
                    "lj_B": 1.0,
                    "lj_rmax": 12.0
                },
            },
        },
        fitting_data={
            "species": ["Fe core", "S core"],
            "2body": {
                "0-0": ["lj_A", "lj_B"],
                "0-1": [],
                "1-1": []
            },
        },
    )
    builder.settings = {"observables": {"energy": {}}}
    builder.structures = {
        "pyrite": get_structure("pyrite"),
        "marcasite": get_structure("marcasite"),
        "zincblende": get_structure("zincblende"),
    }
    builder.observables = {
        "pyrite": Dict(dict={
            "energy": -1,
            "energy_units": "eV"
        }),
        "marcasite": Dict(dict={
            "energy": -1,
            "energy_units": "eV"
        }),
        "zincblende": Dict(dict={
            "energy": 1,
            "energy_units": "eV"
        }),
    }

    calc_node = run_get_node(builder).node

    db_test_app.check_calculation(calc_node, ["results", "potential"])

    result = recursive_round(calc_node.outputs.results.get_dict(), 6)
    for key in [
            "parser_version",
            "peak_dynamic_memory_mb",
            "opt_time_second",
            "total_time_second",
    ]:
        result.pop(key, None)
    data_regression.check({
        "results": result,
        "potential": calc_node.outputs.potential.attributes
    })