44import random
55
66from gemd .entity .attribute import Condition , Parameter , Property , PropertyAndConditions
7- from gemd .entity .bounds import IntegerBounds , RealBounds , CategoricalBounds , CompositionBounds
7+ from gemd .entity .bounds import IntegerBounds , RealBounds , CategoricalBounds , CompositionBounds , \
8+ MolecularStructureBounds
89from gemd .entity .object import ProcessSpec , ProcessRun , MaterialSpec , MaterialRun , \
910 MeasurementSpec , MeasurementRun , IngredientSpec , IngredientRun
1011from gemd .entity .template import ProcessTemplate , MaterialTemplate , MeasurementTemplate , \
1112 PropertyTemplate , ParameterTemplate , ConditionTemplate
1213from gemd .entity .value import NominalInteger , UniformInteger , \
1314 NominalReal , NormalReal , UniformReal , \
1415 NominalCategorical , DiscreteCategorical , \
15- NominalComposition , EmpiricalFormula
16+ NominalComposition , EmpiricalFormula , \
17+ Smiles , InChI
1618from gemd .enumeration .origin import Origin
1719
1820from gemd .entity .util import complete_material_history , make_instance
@@ -113,6 +115,11 @@ def make_cake_templates():
113115 description = "The chemical formula of a material" ,
114116 bounds = CompositionBounds (components = EmpiricalFormula .all_elements ())
115117 )
118+ tmpl ["Molecular Structure" ] = PropertyTemplate (
119+ name = "Molecular Structure" ,
120+ description = "The molecular structure of the material" ,
121+ bounds = MolecularStructureBounds ()
122+ )
116123
117124 # Objects
118125 tmpl ["Baking in an oven" ] = ProcessTemplate (
@@ -165,7 +172,8 @@ def make_cake_templates():
165172 name = "Formulaic Material" ,
166173 description = "A material with chemical characterization" ,
167174 properties = [
168- tmpl ["Chemical Formula" ]
175+ tmpl ["Chemical Formula" ],
176+ tmpl ["Molecular Structure" ]
169177 ]
170178 )
171179 tmpl ["Icing" ] = ProcessTemplate (name = "Icing" ,
@@ -431,7 +439,12 @@ def ingredient_kwargs(material):
431439 ],
432440 notes = 'Plain old NaCl' ,
433441 properties = [
434- PropertyAndConditions (Property (name = 'Formula' , value = EmpiricalFormula ("NaCl" )))
442+ PropertyAndConditions (Property (name = 'Formula' , value = EmpiricalFormula ("NaCl" ))),
443+ PropertyAndConditions (
444+ Property (name = 'InChI' ,
445+ value = InChI ("InChI=1S/ClH.Na/h1H;/q;+1/p-1" ),
446+ template = tmpl ["Molecular Structure" ])
447+ )
435448 ]
436449 )
437450 IngredientSpec (
@@ -456,7 +469,13 @@ def ingredient_kwargs(material):
456469 ],
457470 notes = 'Sugar' ,
458471 properties = [
459- PropertyAndConditions (Property (name = "Formula" , value = EmpiricalFormula ("C12H22O11" )))
472+ PropertyAndConditions (Property (name = "Formula" , value = EmpiricalFormula ("C12H22O11" ))),
473+ PropertyAndConditions (
474+ Property (name = 'SMILES' ,
475+ value = Smiles ("C(C1C(C(C(C(O1)OC2(C(C(C(O2)CO)O)O)CO)O)O)O)O" ),
476+ template = tmpl ["Molecular Structure" ]
477+ )
478+ )
460479 ]
461480 )
462481 IngredientSpec (
@@ -670,9 +689,10 @@ def make_cake(seed=None, tmpl=None, cake_spec=None):
670689 std = 0.05 * item .spec .absolute_quantity .nominal ,
671690 units = item .spec .absolute_quantity .units )
672691 if item .spec .volume_fraction is not None :
692+ # The only element here is dry mix, and it's almost entirely flour
673693 item .volume_fraction = \
674- NormalReal (mean = fuzz * item .spec .volume_fraction .nominal ,
675- std = 0.05 * item . spec . volume_fraction . nominal ,
694+ NormalReal (mean = 0.01 * ( fuzz - 0.5 ) + item .spec .volume_fraction .nominal ,
695+ std = 0.005 ,
676696 units = item .spec .volume_fraction .units )
677697 if item .spec .mass_fraction is not None :
678698 item .mass_fraction = \
0 commit comments