RMF
Toggle main menu visibility
multistate.py
1
## \example multistate.py
2
# Show how to create an detect files where frames represent multiple
3
# states of the same thing.
4
5
import
RMF
6
7
tfn = RMF._get_temporary_file_path(
"multistate.rmf3"
)
8
print(
"File is"
, tfn)
9
10
fh =
RMF.create_rmf_file
(tfn)
11
rh = fh.get_root_node()
12
pf = RMF.ParticleFactory(fh)
13
bf = RMF.BondFactory(fh)
14
sf = RMF.StateFactory(fh)
15
16
17
def
create_hierarchy(state):
18
ns = []
19
rt = rh.add_child(
"state"
+ str(state), RMF.REPRESENTATION)
20
sf.get(rt).set_static_state_index(state)
21
for
i
in
range(0, 3):
22
n = rt.add_child(str(i), RMF.REPRESENTATION)
23
ns.append(n)
24
pf.get(n).set_static_mass(1)
25
pf.get(n).set_static_radius(1)
26
for
i
in
range(0, 2):
27
b = rt.add_child(
"b"
, RMF.BOND)
28
bd = bf.get(b)
29
bd.set_bonded_0(ns[i].get_id().get_index())
30
bd.set_bonded_1(ns[i + 1].get_id().get_index())
31
return
ns
32
33
all_ps = []
34
for
i
in
range(0, 3):
35
all_ps.append(create_hierarchy(i))
36
37
for
frame
in
range(0, 4):
38
fh.add_frame(str(i), RMF.FRAME)
39
for
state, sps
in
enumerate(all_ps):
40
for
particle, p
in
enumerate(sps):
41
pf.get(
42
p).set_coordinates(
RMF.Vector3
(particle + frame + .1 * state,
43
frame + .1 * state,
44
frame + .1 * state))
RMF::Vector< 3U >
RMF::create_rmf_file
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.