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

Conditions don't accept material node #51

@dylanwal

Description

@dylanwal

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()


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions