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

Commit

Permalink
Use inventory material name/position indexing in tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmello committed Jul 13, 2022
1 parent b8da289 commit 5ecb701
Showing 1 changed file with 48 additions and 14 deletions.
62 changes: 48 additions & 14 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ api.save(coll)

### Create an Experiment node
``` py
expt = cript.Experiment(collection=coll, name="Anionic Polymerization of Styrene with SecBuLi")
expt = cript.Experiment(
collection=coll,
name="Anionic Polymerization of Styrene with SecBuLi"
)
api.save(expt)
```

Expand Down Expand Up @@ -66,11 +69,11 @@ api.save(prcs)
### Add Ingredient nodes to the Process node
First, let's grab the Material nodes we need from the Inventory node.
``` py
solution = next((mat for mat in inv.materials if mat.name == 'SecBuLi solution 1.4M cHex'), None)
toluene = next((mat for mat in inv.materials if mat.name == 'toluene'), None)
styrene = next((mat for mat in inv.materials if mat.name == 'styrene'), None)
butanol = next((mat for mat in inv.materials if mat.name == '1-butanol'), None)
methanol = next((mat for mat in inv.materials if mat.name == 'methanol'), None)
solution = inv['SecBuLi solution 1.4M cHex']
toluene = inv['toluene']
styrene = inv['styrene']
butanol = inv['1-butanol']
methanol = inv['methanol']
```
Next, we'll define Quantity nodes indicating the amount of each Ingredient.
``` py
Expand All @@ -82,11 +85,31 @@ workup_qty = cript.Quantity(key="volume", value=100, unit="ml")
```
Next, we'll create Ingredient nodes for each.
``` py
initiator = cript.Ingredient(keyword="initiator" ,material=solution, quantities=[initiator_qty])
solvent = cript.Ingredient(keyword="solvent" ,material=toluene, quantities=[solvent_qty])
monomer = cript.Ingredient(keyword="monomer" ,material=styrene, quantities=[monomer_qty])
quench = cript.Ingredient(keyword="quench" ,material=butanol, quantities=[quench_qty])
workup = cript.Ingredient(keyword="workup" ,material=methanol, quantities=[workup_qty])
initiator = cript.Ingredient(
keyword="initiator",
material=solution,
quantities=[initiator_qty]
)
solvent = cript.Ingredient(
keyword="solvent",
material=toluene,
quantities=[solvent_qty]
)
monomer = cript.Ingredient(
keyword="monomer",
material=styrene,
quantities=[monomer_qty]
)
quench = cript.Ingredient(
keyword="quench",
material=butanol,
quantities=[quench_qty]
)
workup = cript.Ingredient(
keyword="workup",
material=methanol,
quantities=[workup_qty]
)
```
Last, we'll add the Ingredient nodes to the Process node.
``` py
Expand All @@ -107,7 +130,12 @@ prcs.add_condition(time)

### Add a Property node to the Process node
``` py
yield_mass = cript.Property(key="yield_mass", value=0.47, unit="g", method="scale")
yield_mass = cript.Property(
key="yield_mass",
value=0.47,
unit="g",
method="scale"
)
prcs.add_property(yield_mass)
```

Expand All @@ -118,9 +146,15 @@ polystyrene = cript.Material(group=group, name="polystyrene")
```
Next, we'll add some Identifier nodes.
``` py
names = cript.Identifier(key="names", value=["poly(styrene)", "poly(vinylbenzene)"])
names = cript.Identifier(
key="names",
value=["poly(styrene)", "poly(vinylbenzene)"]
)
bigsmiles = cript.Identifier(
key="bigsmiles",
value="[H]{[>][<]C(C[>])c1ccccc1[<]}C(C)CC"
)
chem_repeat = cript.Identifier(key="chem_repeat", value="C8H8")
bigsmiles = cript.Identifier(key="bigsmiles", value="[H]{[>][<]C(C[>])c1ccccc1[<]}C(C)CC")
cas = cript.Identifier(key="cas", value="100-42-5")

polystyrene.add_identifier(names)
Expand Down

0 comments on commit 5ecb701

Please sign in to comment.