-
Notifications
You must be signed in to change notification settings - Fork 0
/
awholefile.cpp
208 lines (197 loc) · 4.77 KB
/
awholefile.cpp
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <iostream>
#include <boost/array.hpp>
#include <vector>
#include <boost/numeric/odeint.hpp>
#include <math.h>
#include "bvpsolvezzz.h"
#define pi 3.1415926
using namespace std;
using namespace boost::numeric::odeint;
/* class bvpsolvezzz
{
private:
vector<double> resulty, resultdydx;
static boost::array<double, 3> resulty_end;
static double EI(double x);
static double dEI(double x);
public:
static double max_k,
D1,
d1,
d2,
L1,
L2,
L3,
EIp,
Es,
F,
q;
bvpsolvezzz();
void bvpsolvezzz_ini(
double _max_k, double _D1, double _d1, double _d2,
double _L1, double _L2, double _L3,
double _EIp, double _Es, double _F, double _q);
~bvpsolvezzz();
static void write_targetFunc_end(const state_type &y, const double x);
static void targetFunc(const state_type &y, state_type &dydx, double x);
static void write_targetFunc(const state_type &y, const double x);
size_t bvpsolver_zzz(func_pr system,
double ya, double yb,
double xa, double xb,
double dx, observer_pr observer0, observer_pr observer);
}; */
vector<double> resulty, resultdydx;
boost::array<double, 3> resulty_end;
double max_k,
D1,
d1,
d2,
L1,
L2,
L3,
EIp,
Es,
F,
q;
void bvpsolvezzz_ini(
double _max_k, double _D1, double _d1, double _d2,
double _L1, double _L2, double _L3,
double _EIp, double _Es, double _F, double _q)
{
max_k = _max_k;
D1 = _D1;
d1 = _d1;
d2 = _d2;
L1 = _L1;
L2 = _L2;
L3 = _L3;
EIp = _EIp;
Es = _Es;
F = _F;
q = _q;
}
void targetFunc(const state_type &y, state_type &dydx, double x)
{
/*
dxdt[2] = -b * x[2] + x[0] * x[1];*/
dydx[0] = y[1];
dydx[1] = -(dEI(x) * y[1] + F * sin(q - y[0])) / EI(x);
// dydx[1] = -2.0 * y[1] / x - y[0] / x / x / x / x;
// -(dEI*y(2)+F*sin(q-y(1)))/EI
}
void write_targetFunc(const state_type &y, const double x)
{
// cout << t << '\t' << x[0] << '\t' << x[1] << '\t' << x[2] << endl;
cout << x << '\t' << y[0] << '\t' << y[1] << endl;
/* resultx.push_back(t);
for (int i = 0; i <= 1; i++)
resultx.push_back(x[i]); */
}
void write_targetFunc_end(const state_type &y, const double x)
{
resulty_end[0] = x;
resulty_end[1] = y[0];
resulty_end[2] = y[1];
}
size_t bvpsolver_zzz(func_pr system,
double ya, double yb,
double xa, double xb,
double dx, observer_pr observer0, observer_pr observer)
{
size_t count = 0;
// typename odeint::unwrap_reference< Observer >::type &obs = observer;
double s_guess = (yb - ya) / (xb - xa), s_guess_pre = 0;
double fais = yb, fais_pre = 0, dfaids = 0;
state_type y; // initial conditions
do
{
y = {{ya, s_guess}};
// observer_pr ob_pr = this->write_targetFunc_end;
integrate(system, y, xa, xb, dx, observer0);
fais_pre = fais;
fais = resulty_end[1] - yb;
dfaids = (fais - fais_pre) / (s_guess - s_guess_pre);
s_guess_pre = s_guess;
s_guess = s_guess - fais / dfaids;
count++;
} while (fais > 0.001 * yb + 1e-6 || fais < -0.001 * yb - 1e-6);
y = {{ya, s_guess}};
integrate(system, y, xa, xb, dx, observer);
return count;
}
double EI(double x)
{
double Ds, EI, Is;
if (x < L1)
{
Ds = D1;
Is = pi / 64 * (pow(Ds, 4) - pow(d1, 4));
EI = Es * Is + EIp;
}
else if (x < L1 + L2)
{
Ds = D1 - ((D1 - d2) / L2) * (x - L1);
Is = pi / 64 * (pow(Ds, 4) - pow(d1, 4));
EI = Es * Is + EIp;
}
else if (x < L1 + L2 + L3)
{
Ds = d2;
Is = pi / 64 * (pow(Ds, 4) - pow(d1, 4));
EI = Es * Is + EIp;
}
else
{
Ds = d1;
Is = pi / 64 * (pow(Ds, 4) - pow(d1, 4));
EI = Es * Is + EIp;
}
return EI;
}
double dEI(double x)
{
double Ds, dEI;
if (x < L1)
dEI = 0;
else if (x < L1 + L2)
{
Ds = D1 - ((D1 - d2) / L2) * (x - L1);
dEI = -Es * pi / 64 * pow(Ds, 3) * 4 * (D1 - d2) / L2;
}
else if (x < L1 + L2 + L3)
dEI = 0;
else
dEI = 0;
return dEI;
}
/* extern "C" __declspec(dllexport) *createBvpSolver()
{
return new bvpsolvezzz;
} */
int main(int argc, char **argv)
{
// bvpsolvezzz *bvp = createBvpSolver();
// bvpsolvezzz_ini(0.3, 0.7, 0.18, 0.2, 0.1, 2.3, 0.2, 1e4, 4.5e6, 2e4, 0.52);
if (argc < 11)
{
cout << "insufficient parameters" << endl;
return 0;
}
else
{
bvpsolvezzz_ini(atof(argv[1]),
atof(argv[2]),
atof(argv[3]),
atof(argv[4]),
atof(argv[5]),
atof(argv[6]),
atof(argv[7]),
atof(argv[8]),
atof(argv[9]),
atof(argv[10]),
atof(argv[11]));
bvpsolver_zzz(targetFunc, 0.0, q, 0.0, 5.0, 0.0001, write_targetFunc_end, write_targetFunc);
// bvpsolver_zzz(targetFunc, 0.0, 5 * sin(1), 1.0 / 3.0 / 3.14, 1.0, 0.001, write_targetFunc_end, write_targetFunc);
// bvpsolver_zzz(targetFunc, 0.0, 5*sin(1), 1.0 / 3.0 / 3.14, 1.0, 0.001, write_targetFunc);
}
}