~reducedmodelling/fluidity/ROM_Non-intrusive-ann

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?xml version="1.0" encoding="UTF-8" ?>
<testproblem>
  <name>p1cv advection equation spatial convergence test</name>
  <owner userid="cwilson"/>
  <tags>flml</tags>
  <problem_definition length="medium" nprocs="1">
    <command_line>fluidity  MMS_A_cv.flml &gt; MMS_A.log; fluidity  MMS_B_cv.flml &gt; MMS_B.log; fluidity  MMS_C_cv.flml &gt; MMS_C.log; fluidity  MMS_D_cv.flml &gt; MMS_D.log</command_line>
  </problem_definition>
  <variables>
    <variable name="ab_convergence_gal_stat" language="python">
from fluidity_tools import stat_parser as stat
from math import log

a_error = stat("MMS_A_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]
b_error = stat("MMS_B_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]

a_error_inf = stat("MMS_A_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]
b_error_inf = stat("MMS_B_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]

print a_error
print b_error

print a_error_inf
print b_error_inf

ab_ratio = a_error / b_error
ab_ratio_inf = a_error_inf / b_error_inf
ab_convergence_gal_stat = [log(ab_ratio, 2), log(ab_ratio_inf, 2)]
    </variable>
    <variable name="bc_convergence_gal_stat" language="python">
from fluidity_tools import stat_parser as stat
from math import log

b_error = stat("MMS_B_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]
c_error = stat("MMS_C_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]

b_error_inf = stat("MMS_B_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]
c_error_inf = stat("MMS_C_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]

print b_error
print c_error

print b_error_inf
print c_error_inf

bc_ratio = b_error / c_error
bc_ratio_inf = b_error_inf / c_error_inf
bc_convergence_gal_stat = [log(bc_ratio, 2), log(bc_ratio_inf, 2)]
    </variable>
    <variable name="cd_convergence_gal_stat" language="python">
from fluidity_tools import stat_parser as stat
from math import log

c_error = stat("MMS_C_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]
d_error = stat("MMS_D_cv.stat")["Burgers"]["AbsoluteDifference"]["cv_l2norm"][-1]

c_error_inf = stat("MMS_C_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]
d_error_inf = stat("MMS_D_cv.stat")["Burgers"]["AbsoluteDifference"]["max"][-1]

print c_error
print d_error

print c_error_inf
print d_error_inf

cd_ratio = c_error / d_error
cd_ratio_inf = c_error_inf / d_error_inf
cd_convergence_gal_stat = [log(cd_ratio, 2), log(cd_ratio_inf, 2)]
    </variable>
    <variable name="a_finish_time" language="python">
from fluidity_tools import stat_parser as stat
a_finish_time = stat("MMS_A_cv.stat")["ElapsedTime"]["value"][-1]
    </variable>
    <variable name="b_finish_time" language="python">
from fluidity_tools import stat_parser as stat
b_finish_time = stat("MMS_B_cv.stat")["ElapsedTime"]["value"][-1]
    </variable>
    <variable name="c_finish_time" language="python">
from fluidity_tools import stat_parser as stat
c_finish_time = stat("MMS_C_cv.stat")["ElapsedTime"]["value"][-1]
    </variable>
    <variable name="d_finish_time" language="python">
from fluidity_tools import stat_parser as stat
d_finish_time = stat("MMS_D_cv.stat")["ElapsedTime"]["value"][-1]
    </variable>
    <variable name="a_final_change" language="python">
import vtktools
from fluidity_tools import stat_parser as stat
vtu = vtktools.vtu("MMS_A_cv_1.vtu")
dt = stat("MMS_A_cv.stat")["dt"]["value"][-1]
a_final_change = max(abs(vtu.GetScalarField("NumericalSolution")-vtu.GetScalarField("OldNumericalSolution"))/dt)
    </variable>
    <variable name="b_final_change" language="python">
import vtktools
from fluidity_tools import stat_parser as stat
vtu = vtktools.vtu("MMS_B_cv_1.vtu")
dt = stat("MMS_B_cv.stat")["dt"]["value"][-1]
b_final_change = max(abs(vtu.GetScalarField("NumericalSolution")-vtu.GetScalarField("OldNumericalSolution"))/dt)
    </variable>
    <variable name="c_final_change" language="python">
import vtktools
from fluidity_tools import stat_parser as stat
vtu = vtktools.vtu("MMS_C_cv_1.vtu")
dt = stat("MMS_C_cv.stat")["dt"]["value"][-1]
c_final_change = max(abs(vtu.GetScalarField("NumericalSolution")-vtu.GetScalarField("OldNumericalSolution"))/dt)
    </variable>
    <variable name="d_final_change" language="python">
import vtktools
from fluidity_tools import stat_parser as stat
vtu = vtktools.vtu("MMS_D_cv_1.vtu")
dt = stat("MMS_D_cv.stat")["dt"]["value"][-1]
d_final_change = max(abs(vtu.GetScalarField("NumericalSolution")-vtu.GetScalarField("OldNumericalSolution"))/dt)
    </variable>
  </variables>
  <pass_tests>
    <test name="ab_convergence_stat: L2 order in [0.8,1.2]" language="python">
assert(abs(ab_convergence_gal_stat[0]-1.0) &lt; 0.2)
    </test>
    <test name="bc_convergence_stat: L2 order in [0.8,1.2]" language="python">
assert(abs(bc_convergence_gal_stat[0]-1.0) &lt; 0.2)
    </test>
    <test name="cd_convergence_stat: L2 order in [0.8,1.2]" language="python">
assert(abs(cd_convergence_gal_stat[0]-1.0) &lt; 0.2)
    </test>
    <test name="checking A finished in less than 3.0" language="python">
assert(a_finish_time-3.0 &lt; 1.E-10)
    </test>
    <test name="checking B finished in less than 2.0" language="python">
assert(b_finish_time-2.0 &lt; 1.E-10)
    </test>
    <test name="checking C finished in less than 1.5" language="python">
assert(c_finish_time-1.5 &lt; 1.E-10)
    </test>
    <test name="checking D finished in less than 1.5" language="python">
assert(d_finish_time-1.5 &lt; 1.E-10)
    </test>
    <test name="checking steady state was reached in A" language="python">
assert(a_final_change &lt; 1.E-10)
    </test>
    <test name="checking steady state was reached in B" language="python">
assert(b_final_change &lt; 1.E-10)
    </test>
    <test name="checking steady state was reached in C" language="python">
assert(c_final_change &lt; 1.E-10)
    </test>
    <test name="checking steady state was reached in D" language="python">
assert(d_final_change &lt; 1.E-10)
    </test>
  </pass_tests>
  <warn_tests>
  </warn_tests>
</testproblem>