def test_read_crystal_fort25(data_regression):
    with open_resource_text(
        "doss", "cubic_rocksalt_orbitals", "cubic-rocksalt_2x1_pdos.doss.f25"
    ) as handle:
        data, arrays = parse_crystal_fort25_aiida(handle)

    data_regression.check(
        {"results": recursive_round(data, 9), "arrays": recursive_round(arrays, 9)}
    )
Exemplo n.º 2
0
def test_calcjob_run(db_test_app, infolder, external_geom, data_regression):
    # type: (AiidaTestApp, str, str) -> None
    """Test running an optimisation calculation."""
    from aiida.engine import run_get_node
    from aiida.orm import SinglefileData

    code = db_test_app.get_or_create_code("crystal17.basic")

    # set up calculation
    builder = code.get_builder()
    builder.metadata = {
        "options": {
            "withmpi": False,
            "resources": {
                "num_machines": 1,
                "num_mpiprocs_per_machine": 1,
            },
            "max_wallclock_seconds": 60,
        }
    }
    # .crystal.ingui # .crystal.d12
    # Prepare input parameters
    with open_resource_binary("crystal", infolder, "INPUT") as handle:
        infile = SinglefileData(file=handle)
    builder.input_file = infile
    if external_geom:
        with open_resource_binary("crystal", infolder, "fort.34") as handle:
            ingui = SinglefileData(file=handle)
        builder.input_external = ingui

    outcome = run_get_node(builder)
    # result = outcome.result
    calc_node = outcome.node

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

    results_attributes = calc_node.outputs.results.attributes
    results_attributes.pop("execution_time_seconds")
    results_attributes.pop("parser_version")
    results_attributes = recursive_round(results_attributes, 9)
    data_regression.check(results_attributes)

    data_regression.check(
        recursive_round(calc_node.outputs.structure.attributes, 9),
        "test_calcjob_run_{}_{}_struct".format(infolder, external_geom),
    )
Exemplo n.º 3
0
def test_run_mgo_scf(db_test_app, sanitise_calc_attr, data_regression):
    # type: (AiidaTestApp) -> None
    """Test running a calculation."""
    parameters = Dict(dict={
        "npoints": 20,
    })
    metadata = {
        "options": {
            "withmpi": False,
            "resources": {
                "num_machines": 1,
                "num_mpiprocs_per_machine": 1,
            },
            "max_wallclock_seconds": 30,
            "input_wf_name": "fort.9",
        }
    }

    # set up calculation
    builder = db_test_app.get_or_create_code("crystal17.ech3").get_builder()
    builder.metadata = metadata
    builder.parameters = parameters

    with resource_context("ech3", "mgo_sto3g_scf") as path:
        builder.wf_folder = RemoteData(
            remote_path=str(path),
            computer=db_test_app.get_or_create_computer())
        output = run_get_node(builder)
        calc_node = output.node

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

    calc_attributes = sanitise_calc_attr(calc_node.attributes)

    results = recursive_round(calc_node.outputs.results.attributes, 5)
    results.pop("execution_time_seconds", None)
    results.pop("parser_version", None)

    data_regression.check({
        "calc":
        calc_attributes,
        "results":
        results,
        "charge":
        recursive_round(calc_node.outputs.charge.attributes, 5),
    })
Exemplo n.º 4
0
def test_success(db_test_app, plugin_name, data_regression):

    retrieved = FolderData()
    with open_resource_binary("ech3", "mgo_sto3g_scf", "main.out") as handle:
        retrieved.put_object_from_filelike(handle, "main.out", mode="wb")

    calc_node = db_test_app.generate_calcjob_node(plugin_name, retrieved)
    with resource_context("ech3", "mgo_sto3g_scf") as path:
        results, calcfunction = db_test_app.parse_from_node(
            plugin_name, calc_node, retrieved_temp=str(path))

    assert calcfunction.is_finished_ok, calcfunction.exception
    assert "results" in results
    assert "charge" in results
    data_regression.check({
        "results":
        recursive_round(results["results"].attributes, 7),
        "charge":
        recursive_round(results["charge"].attributes, 7),
    })
Exemplo n.º 5
0
def test_calcfunction_band_gap(db_test_app, data_regression):
    data = get_test_data("edge_at_fermi")
    array = ArrayData()
    array.set_array("energies", np.array(data.energies))
    array.set_array("total", np.array(data.densities))
    outputs, node = calcfunction_band_gap.run_get_node(
        doss_array=array,
        doss_results=Dict(dict={
            "fermi_energy": data.fermi,
            "units": {
                "energy": "eV"
            }
        }),
        dtol=Float(1e-6),
        try_fshifts=List(list=data.try_fshifts),
        metadata={"store_provenance": True},
    )
    assert node.is_finished_ok, node.exit_status
    assert "results" in node.outputs
    data_regression.check(recursive_round(node.outputs.results.attributes, 4))
def test_parse_fort9(data_regression):
    with open_resource_binary("ech3", "mgo_sto3g_scf", "fort.9") as handle:
        results = parse_fort9(handle)

    data_regression.check(recursive_round(results._asdict(), 7))
def test_read_density_cube(data_regression):

    with open_resource_text("ech3", "mgo_sto3g_scf", "DENS_CUBE.DAT") as handle:
        data = read_gaussian_cube(handle, return_density=True)._asdict()
    data.pop("density")
    data_regression.check(recursive_round(data, 2))
Exemplo n.º 8
0
def test_crystal_stdout_files(name, filepath, data_regression):
    """Test reading stdout file from crystal17."""
    content = read_resource_text(*filepath)
    output = read_crystal_stdout(content)
    output = recursive_round(output, 12)
    data_regression.check(output)
def test_full_files(name, filepath, data_regression):
    content = read_resource_text(*filepath)
    output = parse_bases.parse_bsets_stdin(content, isolated=False)
    output = recursive_round(output, 12)
    data_regression.check(output)
Exemplo n.º 10
0
def test_single_bases(filename, data_regression):
    content = read_resource_text("basis_sets", "manual_examples", filename + ".basis")
    output = parse_bases.parse_bsets_stdin(content, isolated=True)
    output = recursive_round(output, 12)
    data_regression.check(output)
Exemplo n.º 11
0
def test_run_nio_afm_failed_opt(
    db_test_app,
    get_structure,
    upload_basis_set_family,
    sanitise_calc_attr,
    data_regression,
):
    # type: (AiidaTestApp) -> None
    """Test running a calculation where the optimisation fails, due to reaching walltime."""
    code = db_test_app.get_or_create_code("crystal17.main")

    # Prepare input parameters
    params = {
        "title": "NiO Bulk with AFM spin",
        "geometry.optimise.type": "FULLOPTG",
        "scf.single": "UHF",
        "scf.k_points": (8, 8),
        "scf.spinlock.SPINLOCK": (0, 15),
        "scf.numerical.FMIXING": 50,
        "scf.post_scf": ["PPAN"],
    }

    instruct = get_structure("NiO_afm")

    kind_data = KindData(
        data={
            "kind_names": ["Ni1", "Ni2", "O"],
            "spin_alpha": [True, False, False],
            "spin_beta": [False, True, False],
        })

    sym_calc = run_get_node(
        WorkflowFactory("crystal17.sym3d"),
        structure=instruct,
        settings=DataFactory("dict")(dict={
            "symprec": 0.01,
            "compute_primitive": True
        }),
    ).node
    instruct = sym_calc.get_outgoing().get_node_by_label("structure")
    symmetry = sym_calc.get_outgoing().get_node_by_label("symmetry")

    upload_basis_set_family()

    # set up calculation
    process_class = code.get_builder().process_class
    builder = process_class.create_builder(
        params,
        instruct,
        "sto3g",
        symmetry=symmetry,
        kinds=kind_data,
        code=code,
        metadata=db_test_app.get_default_metadata(),
        unflatten=True,
    )

    outputs, calc_node = run_get_node(builder)
    # print(get_calcjob_report(calc_node))
    assert "optimisation" in outputs
    assert "results" in outputs

    calc_attributes = sanitise_calc_attr(calc_node.attributes)
    calc_attributes["retrieve_list"] = sorted(calc_attributes["retrieve_list"])

    results_attributes = outputs["results"].attributes
    results_attributes.pop("execution_time_seconds")
    results_attributes.pop("parser_version")
    results_attributes = recursive_round(results_attributes, 12)

    data_regression.check({
        "calc_node": calc_attributes,
        "outputs": sorted(outputs.keys()),
        "results": results_attributes,
        "optimisation": outputs["optimisation"].attributes,
    })
Exemplo n.º 12
0
def test_run_nio_afm_fullopt(db_test_app, get_structure,
                             upload_basis_set_family, data_regression):
    # type: (AiidaTestApp) -> None
    """Test running a calculation."""
    code = db_test_app.get_or_create_code("crystal17.main")

    # Prepare input parameters
    params = {
        "title": "NiO Bulk with AFM spin",
        "geometry.optimise.type": "FULLOPTG",
        "scf.single": "UHF",
        "scf.k_points": (8, 8),
        "scf.spinlock.SPINLOCK": (0, 15),
        "scf.numerical.FMIXING": 30,
        "scf.post_scf": ["PPAN"],
    }

    instruct = get_structure("NiO_afm")

    kind_data = KindData(
        data={
            "kind_names": ["Ni1", "Ni2", "O"],
            "spin_alpha": [True, False, False],
            "spin_beta": [False, True, False],
        })

    sym_calc = run_get_node(
        WorkflowFactory("crystal17.sym3d"),
        structure=instruct,
        settings=DataFactory("dict")(dict={
            "symprec": 0.01,
            "compute_primitive": True
        }),
    ).node
    instruct = sym_calc.get_outgoing().get_node_by_label("structure")
    symmetry = sym_calc.get_outgoing().get_node_by_label("symmetry")

    upload_basis_set_family()

    # set up calculation
    process_class = code.get_builder().process_class
    builder = process_class.create_builder(
        params,
        instruct,
        "sto3g",
        symmetry=symmetry,
        kinds=kind_data,
        code=code,
        metadata=db_test_app.get_default_metadata(),
        unflatten=True,
    )

    output = run_get_node(builder)
    calc_node = output.node

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

    results_attributes = calc_node.outputs.results.attributes
    results_attributes.pop("execution_time_seconds")
    results_attributes.pop("parser_version")
    results_attributes = recursive_round(results_attributes, 9)

    data_regression.check(results_attributes)

    data_regression.check(
        recursive_round(calc_node.outputs.structure.attributes, 9),
        "test_run_nio_afm_fullopt_struct",
    )
def test_read_props_stdout_doss(data_regression):

    content = read_resource_text("doss", "mgo_sto3g_scf", "main.out")
    data = read_properties_stdout(content)
    data_regression.check(recursive_round(data, 2))
Exemplo n.º 14
0
def test_read_fileobj(db_test_app, data_regression):
    with open_resource_binary("ech3", "mgo_sto3g_scf",
                              "DENS_CUBE.DAT") as handle:
        node = GaussianCube(handle)
    data_regression.check(recursive_round(node.attributes, 5))
Exemplo n.º 15
0
def test_read_filepath(db_test_app, data_regression):
    with resource_context("ech3", "mgo_sto3g_scf", "DENS_CUBE.DAT") as path:
        node = GaussianCube(str(path))
    data_regression.check(recursive_round(node.attributes, 5))