找回密码
 注册
Simdroid-非首页
查看: 323|回复: 3

[3.编程] 照 《Maple高级应用和经典实例》 做的小车过桥的例子,运行不了

[复制链接]
发表于 2015-1-27 08:05:11 | 显示全部楼层 |阅读模式 来自 云南
各位大侠,编程高手:
以下是照这本书
《Maple高级应用和经典实例》
做的小车过桥的例子,运行不了啊,请帮忙看看


restart;
with(plots);
with(plottools);
L := 20;
F := 10^4;
nx := 25;
dL := L/nx;
a := 1/2;
b := 1/2;
d := 1;
e := 1;
f := 1/2;
n := 3;
width := [a+b+d+b+a, b, b];
height := [f, e, e];
cogy := [a+b+(1/2)*d, a+(1/2)*b, a+b+d+(1/2)*b];
cogz := [(1/2)*f, f+(1/2)*e, f+(1/2)*e];
Rmod := 3*10^10;
crosssec := proc (n, B, H)
local i, il, A;
for i to n do
A[i]:= B[i]*H[i];
end do;
A:= sum(A[il], il =1 .. n);
end proc;
cog := proc (n, B, H, ya, za)
local i, il, yc, zc, A, Ay, Az, AA, AAy, AAz, yzc;
for i to n do
A[i] := B[i]*H[i];
Ay[i] := A[i]*ya[i];
Az[i]:= A[i]*za[i];
end do;
AA := sum(A[i], il = 1 .. n);
AAy:= sum(Ay[i], il = 1 .. n);
AAz := sum(Az[i], il = 1 .. n);
yc = AAy/AA;
zc = AAz/AA;
yzc := [yc, zc];
end proc;
inertia := proc (n, B, H, ya, za, yzc)
local i, il, yc, zc, yz, A, Ay, Az, IIy, IIz, Iy, Iz, IAy, IAz, AA, AAy, AAz, II;
yc := yzc[1];
zc := yzc[2];
for i to n do
A[i] := B[i]*H[i];
end do;
for i to n do
Iy[i]:= (1/12)*B[i]*H[i]^3;
Iz[i] := (1/12)*H[i]*B[i]^3;
IAy[i] := A[i]*(za[i]-zc)^2;
IAz[i]:= A[i]*(ya[i]-yc)^2;
end do;
IIy := sum(Iy[il]+IAy[il], il = 1 .. n);
IIz := sum(Iz[il]+IAz[il], il = 1 .. n);
II := [IIy, IIz];
end proc;
moment := proc (x, xF, L, F)
local M;
M(x) := piecewise(x <= xF, F*(L-xF)*x/L, xF < x, F*(L-xF)*x/L-F*(x-xF));
end proc;
deform := proc (x, xF, L, EI, M)
local R, w, eq1, eq2, RB1, RB2, lsg, dfrm;
eq1 := (diff(R(x), x))*EI = M;
eq2 := I*(diff(w(x), x)) = R(x);
RB1 := w(0) = 0;
RB2 := w(L) = 0;
lsg := dsolve({eq1, eq2, RB1, RB2}, {R(x), w(x)});
assign(lsg);
dfrm := [w(x), R(x)];
end proc;
transrot:=porc(XY,dxy,phi)   
local X,Y,dx,dy,x,y,xy;  
X:=XY[1];
Y:=XY[2];  
dx:=dxy[1];
dy:=dxy[2];  
x:=X*cos(phi)+Y*sin(phi)+dx;  
y:=X*sin(phi)+Y*cos(phi)+dy;  
xy:=[x,y];  
end;
carplot:=proc(dx,dy,phi)   
local XY,x,y,car,wheel1,wheel2,win1,win2,win3,win4,P,i;
x[1]:=-1;
y[1]:=0.25;  
x[2]:=1;
y[2]:=0.25;  
x[3]:=-1.5;
y[3]:=0.5;  
x[4]:=1.5;
y[4]:=0.5;  
x[5]:=1.3;
y[5]:=1;  
x[6]:=0.5;
y[6]:=1;
x[7]:=0.3;
y[7]:=1.5;  
x[8]:=-1.3;
y[8]:=1.5;  
x[9]:=-1.5,
y[9]:=0.5;  
x[10]:=-1.4,
y[10]:=1;  
x[11]:=0.3,
y[11]:=1;  
x[12]:=0.5,
y[12]:=0.5;  
x[13]:=-0.5,
y[13]:=1.5;  
x[14]:=-0.5,
y[14]:=0.5;
for i from 1 by 1 to 14 do  
XY:=transrot([x[i],y[i]],[dx,dy],phi);  
x[i]:=XY[1];  
y[i]:=XY[2];  
od;  
win1:=curve([[x[6],y[6]],[x[10],y[10]]],color=blue,thickness=2);  
win2:=curve([[x[7],y[7]],[x[11],y[11]]],color=blue,thickness=2);  
win3:=curve([[x[6],y[6]],[x[12],y[12]]],color=blue,thickness=2);  
win4:=curve([[x[13],y[13]],[x[14],y[14]]],color=blue,thickness=2);  
wheel1:=circle([x[1],y[1]],color=black,thickness=2);  
wheel2:=circle([x[2],y[2]],color=black,thickness=2);  
car:=curve([seq([x[i],y[i]],i=3..9)],color=blue,thickness=2);  
P:=display({car,wheel1,wheel2,win1,win2,win3,win4});  
end;
support:=proc(C,h);   
local P0,P1,P2,P3,PL1,PL2,P;  
P0:=[C[1]+h*sqrt(2)/4,C[2]-h*sqrt(2)/4];  
P1:=[C[1]+h,C[2]-h];  
P2:=[C[1]-h,C[2]-h];  
P3:=[C[1]-h*sqrt(2)/4,C[2]-h*sqrt(2)/4];  
PL1:=curve(C,h/2,color=magenta,thickness=2);  
PL2:=curve([P0,P1,P2,P3],color=magenta,thickness=2);  
P:=display([PL1,PL2]);  
end;
bridgeplot := proc (L)
local x, y, Q, i, P1, P2, P3, P4, P;
P1 := support([0, 0], (1/50)*L);
P2 := support([L, 0], (1/50)*L);
P3 := curve([[-(1/10)*L, 0], [0, 0]], color = black, thickness = 2);
P4 := curve([[L, 0], [(11/10)*L, 0]], color = black, thickness = 2);
P := display([P1, P2, P3, P4]);
end proc;
plotsol := proc (x, xF, L, w, R)
local W, V, Pfeil, Car, Bridge, Beam, P;
W(x) := piecewise(x < 0, 0, 0 <= x and x <= L, 50000*w, L < x, 0);
V(x) := piecewise(x < 0, 0, 0 <= x and x <= L, arctan(50000*R), L < x, 0);
Car := carplot(xF, subs(x = xF, W(x)), subs(x = xF, V(x)));
Bridge := bridgeplot(L);
Pfeil := arrow([xF, subs(x = xF, W(x)+2)], [xF, subs(x = xF, W(x))], (1/200)*L, (1/50)*L, (1/100)*L, color = red);
Beam := plot(W(x), x = -(1/10)*L .. (11/10)*L, color = black, thickness = 2);
P := display(Bridge, Car, Pfeil, Beam);
end proc;
stressplot := proc (x, z, xF, L, sigma, zmin, zmax)
local S, Pfeil, Stress, P;
Pfeil := arrow([xF, -(3/2)*zmax+(1/2)*zmin], [xF, -zmax], (1/200)*L, (1/50)*L, (1/100)*L, color =red);
S(x, z) := sigma;
Stress := contourplot(S(x, z), x = 0 .. L, z = -zmax .. -zmin, grid = [50, 10], filled = true, contours = 5, coloring = [red, green]);
P := display(Pfeil, Stress);
end proc;
yzc := cog(n, width, height, cogy, cogz);
发表于 2015-1-27 10:22:03 | 显示全部楼层 来自 湖南湘潭
Simdroid开发平台
代码可读性太差,语法错误太多。
每一个Proc后面都要加一个 end proc,而不是end。
另外 有一个 关键词proc,都误写为 porc。

评分

1

查看全部评分

回复 不支持

使用道具 举报

 楼主| 发表于 2015-2-1 09:57:42 | 显示全部楼层 来自 云南昆明
谢谢
thanks
vielen danke
回复 不支持

使用道具 举报

发表于 2015-3-5 16:00:57 | 显示全部楼层 来自 四川成都
谁那有这本书呢?我找不到呢Maple高级应用和经典实例
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-25 13:07 , Processed in 0.033499 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表