1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from deter import topdl |
---|
4 | |
---|
5 | elems = [] # elements in the topology |
---|
6 | subs = [] # substrates in the topology |
---|
7 | |
---|
8 | # Create the center node and put it in the element list. (Name is set |
---|
9 | # explicitly) |
---|
10 | center = topdl.Computer(name='center') |
---|
11 | elems.append(center) |
---|
12 | |
---|
13 | # Connect 10 satellites |
---|
14 | for i in range(0,10): |
---|
15 | # Create a substrate to join the new element to center |
---|
16 | link = topdl.Substrate('link%d' % i) |
---|
17 | # Create the new element (n-i) and connect it to the new substrate with an |
---|
18 | # Interface object |
---|
19 | node = topdl.Computer(name='n-%d' % i, interface=[ |
---|
20 | topdl.Interface(substrate=['link%d' %i])]) |
---|
21 | # Add an interface to center linking it to the new substrate |
---|
22 | center.interface.append(topdl.Interface(substrate=['link%d' %i])) |
---|
23 | |
---|
24 | # Add the new link and node to the lists |
---|
25 | subs.append(link) |
---|
26 | elems.append(node) |
---|
27 | |
---|
28 | # Create the topology from the lists. This names the unnamed interfaces and |
---|
29 | # makes connections. |
---|
30 | top = topdl.Topology(elements=elems, substrates=subs) |
---|
31 | |
---|
32 | # Print the XML |
---|
33 | print topdl.topology_to_xml(top, top='experiment') |
---|
34 | |
---|