Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Conditions don't accept material node #51

Open
dylanwal opened this issue Oct 31, 2022 · 0 comments
Open

Conditions don't accept material node #51

dylanwal opened this issue Oct 31, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@dylanwal
Copy link
Contributor

dylanwal commented Oct 31, 2022

I am creating two materials, with the first material (water) being passed as a Condition into the THF Property.

The issue material=water should be accepted.

import cript as c


def make_material(project: c.Project):
    water = c.Material(
        project=project,
        group=project.group,
        name="water",
        identifiers=[
            c.Identifier("preferred_name", "water"),
            c.Identifier("names", ["h2o", "dihydrogen oxide"]),
            c.Identifier("cas", "7732-18-5"),
            c.Identifier("smiles", "O"),
            c.Identifier("chem_formula", "H2O"),
            c.Identifier("pubchem_cid", 962),
            c.Identifier("inchi_key", "XLYOFNOQVPJJNP-UHFFFAOYSA-N"),
        ],
        properties=[
            c.Property(key="phase", value="liquid"),
            c.Property(key="color", value="colorless"),
            c.Property(
                key="molar_mass", value=18.015, unit="g/mol", method="prescribed"
            ),
        ],
    )
    water.save()

    thf = c.Material(
        project=project,
        group=project.group,
        name="thf",
        identifiers=[
            c.Identifier("preferred_name", "tetrahydrofuran"),
            c.Identifier(
                "names",
                [
                    "oxolane",
                    "1,4-epoxybutane",
                    "oxacyclopentane",
                    "THF",
                    "butylene oxide",
                    "cyclotetramethylene oxide",
                ],
            ),
            c.Identifier("cas", "109-99-9"),
            c.Identifier("smiles", "C1CCOC1"),
            c.Identifier("chem_formula", "C4H8O"),
            c.Identifier("pubchem_cid", 8028),
            c.Identifier("inchi_key", "WYURNTSHIVDZCO-UHFFFAOYSA-N"),
        ],
        properties=[
            c.Property(key="phase", value="liquid"),
            c.Property(
                key="solubility",
                value=1,
                unit="g/ml",
                conditions=[
                    c.Condition(key="temperature", value=20, unit="degC"),
                    c.Condition(key="material", material=water),
                ],
            ),
        ],
    )

    thf.save()


def main():
    # API login
    import pathlib
    host = "criptapp.org"
    with open(str(pathlib.Path(__file__).parent.parent) + "\\api_key.txt", "r") as f:
        token = f.read()
    api = c.API(host, token)

    # make material
    project = c.Project.get(name="test_sdk_project")
    make_material(project)


if __name__ == "__main__":
    main()


@dylanwal dylanwal changed the title Paginator can't handle multiple additions Conditions don't accept material node Nov 1, 2022
@dylanwal dylanwal added the bug Something isn't working label Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant