Skip to content

Commit b608b01

Browse files
committed
Add chemistry model.
1 parent 595b945 commit b608b01

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

tests/dbsetup/chemistry.esdl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
INSERT Element {
2+
name := 'Hydrogen',
3+
symbol := 'H',
4+
number := 1,
5+
valence := 1,
6+
weight := 1.0080,
7+
};
8+
INSERT Element {
9+
name := 'Helium',
10+
symbol := 'He',
11+
number := 2,
12+
valence := 0,
13+
weight := 4.0026,
14+
};
15+
INSERT Element {
16+
name := 'Lithium',
17+
symbol := 'Li',
18+
number := 3,
19+
valence := 1,
20+
weight := 6.94,
21+
};
22+
INSERT Element {
23+
name := 'Beryllium',
24+
symbol := 'Be',
25+
number := 4,
26+
valence := 2,
27+
weight := 9.0122,
28+
};
29+
INSERT Element {
30+
name := 'Boron',
31+
symbol := 'B',
32+
number := 5,
33+
valence := 3,
34+
weight := 10.81,
35+
};
36+
INSERT Element {
37+
name := 'Carbon',
38+
symbol := 'C',
39+
number := 6,
40+
valence := 4,
41+
weight := 12.011,
42+
};
43+
INSERT Element {
44+
name := 'Nitrogen',
45+
symbol := 'N',
46+
number := 7,
47+
valence := 5,
48+
weight := 14.007,
49+
};
50+
INSERT Element {
51+
name := 'Oxygen',
52+
symbol := 'O',
53+
number := 8,
54+
valence := 6,
55+
weight := 15.999,
56+
};
57+
INSERT Element {
58+
name := 'Fluorine',
59+
symbol := 'F',
60+
number := 9,
61+
valence := 7,
62+
weight := 18.998,
63+
};
64+
INSERT Element {
65+
name := 'Neon',
66+
symbol := 'Ne',
67+
number := 10,
68+
valence := 0,
69+
weight := 20.180,
70+
};

tests/dbsetup/chemistry.gel

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module default {
2+
type Named {
3+
required name: std::str;
4+
};
5+
6+
type Element extending Named {
7+
required symbol: str;
8+
required number: int64;
9+
required valence: int64;
10+
required weight: float64;
11+
};
12+
13+
# We do this for now, since self multi links aren't well supported
14+
type BaseAtom {
15+
# Single link no props
16+
required element: Element;
17+
18+
# Computed single prop
19+
weight := sum(.element.weight);
20+
};
21+
22+
type RefAtom extending BaseAtom {
23+
# Multi link with props
24+
multi bonds: BaseAtom {
25+
count: int64;
26+
}
27+
28+
# Computed single link
29+
compound := .<atoms[is Compound];
30+
};
31+
32+
type Compound extending Named {
33+
# Multi link no props
34+
multi atoms: RefAtom;
35+
36+
# Multi prop
37+
multi alternate_names: str;
38+
};
39+
40+
type Reactor {
41+
# Computed multi link
42+
multi atoms := .<reactor[is Atom];
43+
44+
# Computed single prop
45+
total_weight := sum(.atoms.element.weight);
46+
# Computed multi prop
47+
atom_weights := .atoms.element.weight;
48+
};
49+
50+
type Atom extending BaseAtom {
51+
# Multi link with props
52+
multi bonds: BaseAtom {
53+
count: int64;
54+
}
55+
56+
# Single link with props
57+
required reactor: Reactor;
58+
59+
# Computed single prop using link props
60+
total_bond_count := sum(.bonds@count);
61+
total_bond_weight := sum(.bonds.weight);
62+
};
63+
}

0 commit comments

Comments
 (0)