/
tests.py
executable file
·53 lines (34 loc) · 1.56 KB
/
tests.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import math
import os
import opencor as oc
def run_simulation(title, file_name_or_url, first=True):
if not first:
print()
print('---------------------------------------')
print(' ' * math.floor((39 - len(title)) / 2) + title)
print('---------------------------------------')
print(' - Open file...')
if file_name_or_url.startswith('https://'):
simulation = oc.open_simulation(file_name_or_url)
else:
simulation = oc.open_simulation(os.path.dirname(__file__) + '/' + file_name_or_url)
print(' - Run file...')
simulation.run()
print(' - Retrieve simulation results...')
results = simulation.results()
print(' - Retrieve states...')
states = results.states()
print(' - Retrieve states\' values...')
x = states['main/x'].values()
y = states['main/y'].values()
z = states['main/z'].values()
oc.close_simulation(simulation)
run_simulation('Local CellML file', '../cellml/lorenz.cellml')
run_simulation('Remote CellML file',
'https://raw.githubusercontent.com/opencor/opencor/master/models/tests/cellml/lorenz.cellml', False)
run_simulation('Local SED-ML file', '../sedml/lorenz.sedml', False)
run_simulation('Remote SED-ML file',
'https://raw.githubusercontent.com/opencor/opencor/master/models/tests/sedml/lorenz.sedml', False)
run_simulation('Local COMBINE archive', '../combine/lorenz.omex', False)
run_simulation('Remote COMBINE archive',
'https://raw.githubusercontent.com/opencor/opencor/master/models/tests/combine/lorenz.omex', False)