-
Notifications
You must be signed in to change notification settings - Fork 0
/
beam.cpp
346 lines (304 loc) · 9.98 KB
/
beam.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#include"beam.h"
#include<fstream>
void beam::loadjizhongli(double& pos, double& force)
{
if(force!=0){
jizhongPos.insert(pos);
loads[pos]+=force;
//for(int i=0;i<51;i++){
//}
}
}
void beam::loadMoment(double& pos, double& me)
{
if(me!=0){
jizhongPos.insert(pos);
meLoads[pos]+=me;
}
}
void beam::loadlin(double& pos1,double& pos2,double& force1,double& force2)
{
for(int i=0;i<201;i++)
{
loads[pos1+i*(pos2-pos1)/200.0]+=(force1+i*(force2-force1)/200.0)*(pos2-pos1)/200;
}
}
void beam::calc()
{
double k=leng/100.0;
for(int i=0;i<101;i++){
bend[i]=bending(i*k);
Fsy[i]=neili(i*k);
innerMz[i]=wanju(i*k);
}
}
//----------------------------------------------------------------------------------------------------
double simpSupBeam::bending(const double& pos)
{
#define left iter->first
#define force iter->second
#define right (leng-iter->first)
double v=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
v+=(pos<left)?-force*right*pos*(leng*leng-pos*pos-right*right)/6.0:
-force*right*(leng/right*(pos-left)*(pos-left)*(pos-left)+(leng*leng-right*right)*pos-pos*pos*pos)/6.0;
}
#undef force
p=meLoads.end();
#define me (iter->second)
for(std::map<double,double>::iterator iter=meLoads.begin();iter!=p;++iter)
{
v+=(pos<left)?me*pos*(leng*leng-3.0*right*right-pos*pos)/6.0:
me*(-pos*pos*pos+3*leng*(pos-left)*(pos-left)+(leng*leng-3.0*right*right)*pos)/6.0;
}
return v/Ela/intia/leng;
#undef left
#undef me
#undef right
}
double simpSupBeam::wanju(const double& pos)
{
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?pos*(leng-iter->first)*iter->second/leng:
(leng-pos)*(iter->first)*iter->second/leng;
}
p=meLoads.end();
for(std::map<double,double>::iterator iter=meLoads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?-pos*iter->second/leng:-pos*iter->second/leng+iter->second;
}
return f;
}
double simpSupBeam::neili(const double& pos)
{
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?-(leng-iter->first)*iter->second/leng:
(iter->first)*iter->second/leng;
}
p=meLoads.end();
for(std::map<double,double>::iterator iter=meLoads.begin() ;iter!=p;++iter){
f+=iter->second/leng;
}
return f;
}
//----------------------------------------------------------------------------------------------------
double caBeam::bending(const double& pos)
{
#define left iter->first
#define force iter->second
#define right (leng-iter->first)
double v=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
v+=(pos<left)?-force*pos*pos*(3.0*left-pos)/6.0:
-force*left*left*(3.0*pos-left)/6.0;
}
#undef force
p=meLoads.end();
#define me (iter->second)
for(std::map<double,double>::iterator iter=meLoads.begin();iter!=p;++iter)
{
v+=(pos<left)?-me*pos*pos/2.0:
-me*left*(pos-left/2.0);
}
return v/Ela/intia;
#undef left
#undef me
#undef right
}
double caBeam::wanju(const double& pos)
{
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?-iter->first*iter->second+pos*iter->second:0;
}
p=meLoads.end();
for(std::map<double,double>::iterator iter=meLoads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?-iter->second:0;
}
return f;
}
double caBeam::neili(const double& pos){
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin();iter!=p;++iter){
f+=(pos<iter->first)?-iter->second:0;
}
return f;
}
//----------------------------------------------------------------------------------------
double overHangingBeam::wanju(const double& pos)
{
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
if((iter->first)<rRestraint){
f+=(pos<rRestraint)?((pos<iter->first)?pos*(rRestraint-iter->first)*iter->second/rRestraint:
(rRestraint-pos)*(iter->first)*iter->second/rRestraint) : 0;}
else{
f-=(pos<iter->first)?((pos<rRestraint)?pos*(iter->first-rRestraint)*iter->second/rRestraint:
iter->second*(leng-pos)-iter->second*(leng-iter->first)) : 0;
}
}
p=meLoads.end();
for(std::map<double,double>::iterator iter=meLoads.begin() ;iter!=p;++iter)
{
f+=(pos<iter->first)?-pos*iter->second/leng:-pos*iter->second/leng+iter->second;
}
return f;
}
/*double overHangingBeam::bending(const double& z0)
{
const double x0=0.0;
const double y0=0.0;
const int nn=100;
double h=rRestraint/nn;
double x1=x0;
double y1=y0;
double z1=z0;
double m1,m2,m3,m4,k1,k2,k3,k4;
for(int n=1;n<(nn+1);n++)
{
k1=h*z1;
m1=h*wanju(x1);
k2=h*(z1+m1/2.0);
m2=h*wanju(x1+h/2.0);
k3=h*(z1+m2/2.0);
m3=h*wanju(x1+h/2.0);
k4=h*(z1+m3);
m4=h*wanju(x1+h);
y1+=(k1+2.0*k2+2.0*k3+k4)/6.0;
z1+=(m1+2.0*m2+2.0*m3+m4)/6.0;
x1+=h;
}
return (y1);
}*/
/*void overHangingBeam::calc()
{
const double eps=.0000001;
double x0=.1,x1=.15;
double x,y=10;
//solving the theta of the start point
do
{
x=x1;
y=bending(x1);
x1=x1-y/(y-bending(x0))*(x1-x0);
x0=x;
} while(fabs(y)>eps);
//x1 is the theta of the start point
double z1=x1;
bend[0]=0;
double h=leng/100;
x1=0;
double y1=0;
double k=leng/100.0;
double m1,m2,m3,m4,k1,k2,k3,k4;
//std::ofstream f1("d:\\me.txt");
for(int n=1;n<(101);++n)
{
k1=h*z1;
m1=h*wanju(x1);
k2=h*(z1+m1/2.0);
m2=h*wanju(x1+h/2.0);
k3=h*(z1+m2/2.0);
m3=h*wanju(x1+h/2.0);
k4=h*(z1+m3);
m4=h*wanju(x1+h);
y1+=(k1+2.0*k2+2.0*k3+k4)/6.0;
z1+=(m1+2.0*m2+2.0*m3+m4)/6.0;
x1+=h;
bend[n]=y1/Ela/intia;
Fsy[n]=neili(n*k);
innerMz[n]=wanju(n*k);
//f1<<x1<<"\t"<<y1<<"\n";
}
//f1.close();
}*/
double overHangingBeam::neili(const double &pos){
double f=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
if(iter->first<rRestraint){
f+=(pos<rRestraint)?((pos<iter->first)?-(rRestraint-iter->first)*iter->second/rRestraint:
(iter->first)*iter->second/rRestraint):0;}
else
{
f+=(pos<iter->first)?((pos<rRestraint)?(iter->second*iter->first/rRestraint-iter->second):
-iter->second):0;
}
}
p=meLoads.end();
for(std::map<double,double>::iterator iter=meLoads.begin() ;iter!=p;++iter)
{
if(iter->first<rRestraint){
f+=(pos<rRestraint)?iter->second/leng:0;
}
else{
f+=(pos<rRestraint)?iter->second/leng:0;
}
}
return f;
}
double overHangingBeam::bending(const double & pos){
#define force iter->second
#define ll rRestraint
#define aa iter->first
#define bb (ll-aa)
//#define loadPos iter->first
double v=0;
std::map<double,double>::iterator p=loads.end();
for(std::map<double,double>::iterator iter=loads.begin() ;iter!=p;++iter)
{
if(iter->first<rRestraint){
v+=(pos<ll)?((pos<aa)?-force*bb*pos/6.0/ll*(ll*ll-pos*pos-bb*bb):
-force*bb/6.0/ll*(ll/bb*(pos-aa)*(pos-aa)*(pos-aa)+(ll*ll-bb*bb)*pos-pos*pos*pos)):
(pos-ll)*(force*aa*bb*(ll+aa)/6.0/ll);
}
#undef aa
#define aa (iter->first-ll)
else{
v+=(pos<iter->first)?((pos<ll)?force*aa*pos*(ll*ll-pos*pos)/6.0/ll:
-force*(pos-ll)/6.0*(aa*(3.0*pos-ll)-(pos-ll)*(pos-ll))):
force*(-(pos-iter->first)*(aa/6.0)*(2.0*ll+3.0*aa)-aa*aa/3.0*(iter->first));
}
}
#undef force
#undef aa
#define me iter->second
p=meLoads.end();
#define aa iter->first
for(std::map<double,double>::iterator iter=meLoads.begin();iter!=p;++iter)
{
if(iter->first>rRestraint){
v+=(pos<iter->first)?((pos<rRestraint)?me*(-pos*pos*pos/rRestraint+rRestraint*pos)/6.0:
-me*(pos*pos*.5-rRestraint*pos/3.0-rRestraint*rRestraint/6.0)):
me*((-iter->first*iter->first*.5+rRestraint*iter->first/3.0+rRestraint*rRestraint/6.0)+
(2.0*rRestraint/3.0-iter->first)*(pos-iter->first));
}
else{
v+=(pos<rRestraint)?((pos<iter->first)?me*pos*(ll*ll-3.0*bb*bb-pos*pos)/ll:
me/ll*(-pos*pos*pos+3.0*ll*(pos-aa)*(pos-aa)+(ll*ll-3.0*bb*bb)*pos)):
(pos-ll)*me/6.0*(ll*ll-3*aa*aa);
}
#undef me
#undef ll
#undef aa
#undef bb
}
return v/Ela/intia;
}