This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ann-detonation-cells_vol.C
144 lines (116 loc) · 3.99 KB
/
ann-detonation-cells_vol.C
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
#include <stdio.h>
#include <math.h>
/* function declaration - network evaluation */
void export_eval(const double*, double*);
/* ------------------------------------------------------------ */
static const double export_in_A[49] = {
4.206140509523913, 0, 0, 0,
0, 0, 0, 0,
0.001403010320791172, 0, 0, 0,
0, 0, 0, 0,
2, 0, 0, 0,
0, 0, 0, 0,
2, 0, 0, 0,
0, 0, 0, 0,
2, 0, 0, 0,
0, 0, 0, 0,
2, 0, 0, 0,
0, 0, 0, 0,
2
};
static const double export_in_b[7] = {
-1.103070254761957, -3.350634063161516, -1, -1,
-1, -1, -1
};
void
export_in(const double *x, double *y)
{
int k = 0, i, j;
for (i = 0; i < 7; ++i) {
y[i] = export_in_b[i];
for (j = 0; j < 7; ++j, ++k) {
y[i] += export_in_A[k] * x[j];
}
}
}
static const double export_out_A[1] = {
1.623426529959797
};
static const double export_out_b[1] = {
1.381498263509058
};
void
export_out(const double *x, double *y)
{
int k = 0, i, j;
for (i = 0; i < 1; ++i) {
y[i] = export_out_b[i];
for (j = 0; j < 1; ++j, ++k) {
y[i] += export_out_A[k] * x[j];
}
}
}
static const double export_w[84] = {
0.04751866688913114, 4.291721196148696, 0.3997680433827465, 0.3851319591342113,
0.9768564975312224, 0.2680103960534636, -0.7073948940978718, -0.297749625062468,
0.007362995998954044, 1.741320368835228, 1.363538307975399, -0.2045656181695363,
0.03758502121946879, 0.002697053428803897, -0.3600160523175535, -1.941630153489091,
0.09353933084680165, 0.5590331000295946, 0.107191653494409, 0.5560876829832736,
-0.02209570889079708, 0.1371708849544222, -0.2664977201257457, -0.1077949638265747,
-0.09134551018427942, -1.696645016696965, -0.310673054750995, -0.1995884152099962,
-0.0588599776113673, 0.3858128295985084, -0.2804718242405412, -0.4584229361863085,
0.1929231361839166, 0.7052589604577051, -0.6601608816220683, -0.2699274000134732,
0.003959123177779801, -0.7064434205887187, -0.196606697249565, 0.1434437115820186,
-0.1347081068941295, -1.372755922126155, 1.503573565766964, 0.3614433983829449,
-0.164558338238105, -0.02979723737845457, -0.6307085674851798, 0.8072373811937822,
-0.04668125162613091, -0.1872464193739344, 0.3462950032502879, -0.3383168340305925,
0.6668795408885293, -0.3878415509277716, 0.2013546700725378, 0.3041990434111474,
0.09913912224952774, 0.5928819763864733, 0.02599099984600142, 0.8871380983891201,
0.5629061231289704, -0.5321835295951162, 0.05973571828373576, -0.4755490640707391,
-0.4088071398325277, -1.010177130148782, 0.2710148107981824, 0.1678733595450359,
0.04832756304483642, -0.134995419456438, 0.5234025856568252, 0.1179744030592867,
-0.08918698257540351, -0.7853038438975632, -0.6928421883587407, -1.551476863178014,
0.5450172590080059, -0.374996263260748, -0.3171544512210595, -0.2771937665435957,
0.03932994764554099, 0.7813123172197314, -0.8250969877770431, 0.9022676588986015
};
void
export_eval(const double *input, double *output)
{
double n[18];
double x;
int k = 0, i = 7, j;
export_in(input, n);
for (; i < 14; ++i) {
x = export_w[k++];
for (j = 0; j < 7; ++j) x += n[j] * export_w[k++];
n[i] = (double)2. / ((double)1. + exp((double)-2 * x)) - (double)1.;
}
for (; i < 17; ++i) {
x = export_w[k++];
for (j = 7; j < 14; ++j) x += n[j] * export_w[k++];
n[i] = (double)2. / ((double)1. + exp((double)-2 * x)) - (double)1.;
}
for (; i < 18; ++i) {
x = export_w[k++];
for (j = 14; j < 17; ++j) x += n[j] * export_w[k++];
n[i] = x;
}
export_out(n + 17, output);
}
int main()
{
/* inputs order:
fuel fraction, adiabatic flame temp. [K], c3h8air, c3h8o2, ch4air, ch4o2, h2air
output:
log10(cellSize [mm])
Below is a test for H2-air, 30% of fuel,
*/
double testinp[7] = {0.3, 2387.261, 0, 0, 0, 0, 1};
double testout = 0.0;
double *inp = testinp;
double *out = &testout;
export_eval(inp, out);
*out = pow(10,*out);
printf("Cell size is %f\n mm", *out);
return 0;
}