Example #1
0
def test_wavefunction(settings, atomic_input):
    atomic_input_dict = atomic_input.dict()
    atomic_input_dict.pop("protocols", None)
    with_wf = AtomicInput(**atomic_input_dict,
                          protocols={"wavefunction": "all"})
    with TCPBClient(settings["tcpb_host"], settings["tcpb_port"]) as TC:
        result = TC.compute(with_wf)

    # Restricted
    assert result.wavefunction is not None
    assert isinstance(result.wavefunction.scf_eigenvalues_a, ndarray)
    assert isinstance(result.wavefunction.scf_occupations_a, ndarray)
    assert result.wavefunction.scf_eigenvalues_b is None
    assert result.wavefunction.scf_occupations_b is None

    atomic_input_dict["keywords"]["restricted"] = False
    with_wf = AtomicInput(**atomic_input_dict,
                          protocols={"wavefunction": "all"})
    with TCPBClient(settings["tcpb_host"], settings["tcpb_port"]) as TC:
        result = TC.compute(with_wf)

    # B occupations since restricted=False
    assert result.wavefunction is not None
    assert isinstance(result.wavefunction.scf_eigenvalues_a, ndarray)
    assert isinstance(result.wavefunction.scf_occupations_a, ndarray)
    assert isinstance(result.wavefunction.scf_eigenvalues_b, ndarray)
    assert isinstance(result.wavefunction.scf_occupations_b, ndarray)
Example #2
0
def test_convthre(settings, atomic_input):
    atomic_input.keywords["convthre"] = 3.0e-5
    with TCPBClient(settings["tcpb_host"], settings["tcpb_port"]) as TC:
        start = time.time()
        TC.compute(atomic_input)
        tight_thresh = time.time() - start

    atomic_input.keywords["convthre"] = 3.0e-2
    with TCPBClient(settings["tcpb_host"], settings["tcpb_port"]) as TC:
        start = time.time()
        TC.compute(atomic_input)
        looser_thresh = time.time() - start

    assert tight_thresh > looser_thresh
Example #3
0
def test_molden_file_creation(settings, atomic_input, test_data_dir):
    # Add molden keywords
    atomic_input.keywords.update({"mo_output": True, "molden": True})
    with TCPBClient(settings["tcpb_host"], settings["tcpb_port"]) as TC:
        result = TC.compute(atomic_input)

    with open(test_data_dir / "water.molden") as f:
        correct_molden = f.read()

    assert result.extras["molden"] == correct_molden
Example #4
0
def test_cisno_casci(settings, ethylene):

    with TCPBClient(host=settings["tcpb_host"], port=settings["tcpb_port"]) as TC:
        # Add in Ethylene atoms
        base_options["atoms"] = ethylene["atoms"]
        options = dict(base_options, **cisno_options)
        results = TC.compute_job_sync(
            "energy", ethylene["geometry"], "angstrom", **options
        )

        for field in fields_to_check:
            assert _round(results[field]) == _round(cisno_casci.correct_answer[field])
Example #5
0
def test_cisno_casci_atomic_input(settings, ethylene, job_output):
    # Construct Geometry in bohr
    geom_angstrom = qcel.Datum("geometry", "angstrom", np.array(ethylene["geometry"]))
    geom_bohr = geom_angstrom.to_units("bohr")

    # Construct Molecule object
    m_ethylene = Molecule.from_data(
        {
            "symbols": ethylene["atoms"],
            "geometry": geom_bohr,
            "molecular_multiplicity": cisno_options["spinmult"],
            "molecular_charge": cisno_options["charge"],
        }
    )

    # Construct AtomicInput
    atomic_input = AtomicInput(
        molecule=m_ethylene,
        driver="energy",
        model=base_options,
        keywords=cisno_options,
    )

    with TCPBClient(host=settings["tcpb_host"], port=settings["tcpb_port"]) as TC:
        # Add in Ethylene atoms
        results = TC.compute(atomic_input)

    # compare only relevant attributes (computed values)
    attrs_to_compare = []
    for attr in dir(results):
        if (
            not (
                attr.startswith("__")
                or attr.startswith("_")
                or callable(attr)
                or attr[0].isupper()
            )
            and attr in fields_to_check
        ):
            attrs_to_compare.append(attr)

    for attr in attrs_to_compare:
        if isinstance(getattr(results, attr), RepeatedScalarFieldContainer):
            assert _round([a for a in getattr(results, attr)]) == _round(
                [a for a in getattr(job_output, attr)]
            )
        else:
            assert getattr(results, attr) == getattr(job_output, attr)
Example #6
0
def test_fomo_casci(settings, ethylene):

    with TCPBClient(host=settings["tcpb_host"], port=settings["tcpb_port"]) as TC:
        options = {
            "method": "hf",
            "basis": "6-31g**",
            "atoms": ethylene["atoms"],
            "charge": 0,
            "spinmult": 1,
            "closed_shell": True,
            "restricted": True,
            "precision": "double",
            "threall": 1e-20,
            "casci": "yes",
            "fon": "yes",
            "closed": 7,
            "active": 2,
            "cassinglets": 2,
            "nacstate1": 0,
            "nacstate2": 1,
        }

        # NACME calculation
        results = TC.compute_job_sync(
            "coupling", ethylene["geometry"], "angstrom", **options
        )

        fields_to_check = [
            "charges",
            "dipole_moment",
            "dipole_vector",
            "energy",
            "orb_energies",
            "orb_occupations",
            "nacme",
            "cas_transition_dipole",
            "cas_energy_labels",
            "bond_order",
        ]

        for field in fields_to_check:
            assert _round(results[field], 4) == _round(
                fomo_casci.correct_answer[field], 4
            )
        print(results)
Example #7
0
    -0.16786485,
    -0.95561368,
    -0.69426370,
    2.15270896,
    0.84221076,
    0.19314809,
    2.16553127,
    -0.97886933,
    0.15232587,
]

if len(sys.argv) != 3:
    print("Usage: {} host port".format(sys.argv[0]))
    exit(1)

with TCPBClient(host=sys.argv[1], port=int(sys.argv[2])) as TC:
    base_options = {
        "method": "hf",
        "basis": "6-31g**",
        "atoms": atoms,
        "charge": 0,
        "spinmult": 1,
        "closed_shell": True,
        "restricted": True,
        "precision": "double",
        "convthre": 1e-8,
        "threall": 1e-20,
    }

    cisno_options = {
        "cisno": "yes",
Example #8
0
def test_ci_overlap(settings, ethylene):

    # Ethylene system
    atoms = ["C", "C", "H", "H", "H", "H"]
    geom = [
        0.35673483,
        -0.05087227,
        -0.47786734,
        1.61445821,
        -0.06684947,
        -0.02916681,
        -0.14997206,
        0.87780529,
        -0.62680155,
        -0.16786485,
        -0.95561368,
        -0.69426370,
        2.15270896,
        0.84221076,
        0.19314809,
        2.16553127,
        -0.97886933,
        0.15232587,
    ]
    geom2 = [
        0.35673483,
        -0.05087227,
        -0.47786734,
        1.61445821,
        -0.06684947,
        -0.02916681,
        -0.14997206,
        0.87780529,
        -0.62680155,
        -0.16786485,
        -0.95561368,
        -0.69426370,
        2.15270896,
        0.84221076,
        0.19314809,
        2.16553127,
        -0.97886933,
        0.15232587,
    ]

    with TCPBClient(host=settings["tcpb_host"], port=settings["tcpb_port"]) as TC:
        base_options = {
            "atoms": atoms,
            "charge": 0,
            "spinmult": 1,
            "closed_shell": True,
            "restricted": True,
            "method": "hf",
            "basis": "6-31g**",
            "precision": "double",
            "threall": 1.0e-20,
            "casci": "yes",
            "closed": 5,
            "active": 6,
            "cassinglets": 10,
        }

        # First run CASCI to get some test CI vectors
        casci_options = {"directci": "yes", "caswritevecs": "yes"}
        options = dict(base_options, **casci_options)
        results = TC.compute_job_sync("energy", geom, "angstrom", **options)

        # Run ci_vec_overlap job based on last job
        overlap_options = {
            "geom2": geom2,
            "cvec1file": os.path.join(results["job_scr_dir"], "CIvecs.Singlet.dat"),
            "cvec2file": os.path.join(results["job_scr_dir"], "CIvecs.Singlet.dat"),
            "orb1afile": os.path.join(results["job_scr_dir"], "c0"),
            "orb2afile": os.path.join(results["job_scr_dir"], "c0"),
        }
        options = dict(base_options, **overlap_options)
        results = TC.compute_job_sync("ci_vec_overlap", geom, "angstrom", **options)

        fields_to_check = [
            "charges",
            "spins",
            "dipole_moment",
            "dipole_vector",
            "orb_energies",
            "orb_occupations",
            "ci_overlap",
            "bond_order",
        ]
        for field in fields_to_check:
            assert _round(results[field]) == _round(ci_overlap.correct_answer[field])