Time series

This example illustrates the TIME_SERIES functionality in Solfec-1.0. The input files for this example are located in the solfec-1.0/examples/time–series directory. These are:

TIME_SERIES object can be used in Solfec-1.0 to prescribe time–dependent constraints and loads. The three minimalist input files included with this example illustrate the ways the time series can be used: Listing 11, Listing 12, Listing 13 below include comments and are self–explanatory. An animated output of the cached–ts.py example is included as video [1].

Listing 11 Listing of basic–ts.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# basic applications of TIME_SERIES (points)
import os
d0 = os.path.dirname(os.path.realpath(__file__))

tms1 = TIME_SERIES (d0+'/ts-data-0.txt');
print 'From file:'
print tms1.times
print tms1.values

list2 = [0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16];
tms2 = TIME_SERIES (list2);
print 'From [t0,v0, t1,v1, ..] list:'
print tms2.times
print tms2.values

list3 = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16]];
tms3 = TIME_SERIES (list3);
print 'From [[t0,v0], [t1,v1], ...] list:'
print tms3.times
print tms3.values

tms4 = tms3.derivative
print 'Derivative:'
print tms4.times
print tms4.values

tms5 = tms3.integral
print 'Integral:'
print tms5.times
print tms5.values
Listing 12 Listing of cached–ts.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# partially cached TIME_SERIES ('data.txt', cache = N) example
import os
d0 = os.path.dirname(os.path.realpath(__file__))

# create SOLFEC object and bulk material
solfec = SOLFEC ('DYNAMIC', 1E-3, 'out/cached-ts')
mat = BULK_MATERIAL (solfec, model = 'KIRCHHOFF',
      young = 1E9, poisson = 0.3, density = 1E3)

# create 10 rigid spheres following along the y-direction
# the time series based displacement history; note that
# in this case we use a unique time series for each body;
# should the number of bodies and the size of the time series
# be large - this would easily lead to using up all memory;
# using partially cached time series allows to avoid this
# issue; in our case we have 100 data points per series and
# we set the partial cache size to 10; this means that only
# 10 points are stored in memory, per series, at any time;
for i in range (1, 11):
  tms = TIME_SERIES (d0+'/ts-data-%d.txt' % i, cache = 10)
  sph = SPHERE ((i, 0, 0), 0.4, 1, 1)
  bod = BODY (solfec, 'RIGID', sph, mat)
  SET_DISPLACEMENT (bod, (i, 0, 0), (0, 1, 0), tms)

# create constraints solver and run simulation
slv = NEWTON_SOLVER()
RUN (solfec, slv, 1.0)
Listing 13 Listing of labeled–ts.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# labeled TIME_SERIES ('data.txt', label = 'string') example
import os
d0 = os.path.dirname(os.path.realpath(__file__))

# create SOLFEC object and bulk material
solfec = SOLFEC ('DYNAMIC', 1E-3, 'out/labeled-ts')
mat = BULK_MATERIAL (solfec, model = 'KIRCHHOFF',
      young = 1E9, poisson = 0.3, density = 1E3)

# create labeled time series object
tms = TIME_SERIES (d0+'/ts-data-1.txt', label = 'data-1')

# create 10 rigid spheres following along the y-direction
# the time series based displacement history; note that
# in this case, because the time series object was labeled,
# only a single copy of the time series object will be used
# internally - saving memory; should 'tms' be unlabeled 10
# separate data sets would be used;
for i in range (0, 10):
  sph = SPHERE ((i, 0, 0), 0.4, 1, 1)
  bod = BODY (solfec, 'RIGID', sph, mat)
  SET_DISPLACEMENT (bod, (i, 0, 0), (0, 1, 0), tms)

# create constraints solver and run simulation
slv = NEWTON_SOLVER()
RUN (solfec, slv, 1.0)
[1]Animated output of the cached–ts.py example from Listing 12.