💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
使用ode45和事件检测可以模拟许多多阶段动力学问题,其中包括模拟弹弓的两阶段过程。弹弓是一种简单而有趣的机械装置,它利用弹性力量将物体发射出去。
在弹弓的第一阶段,弹弓臂被扭曲,使弹丸获得加速。在第二阶段,弹丸在空中飞行。使用ode45和事件检测可以模拟这两个阶段的过程。
在模拟第一阶段时,可以使用ode45来解决弹弓臂的运动方程。在这个过程中,弹弓臂的角度随着时间的变化而变化,可以通过设置初始角度和弹弓臂的弹性系数来模拟这个过程。当弹弓臂旋转到一定角度时,可以使用事件检测来检测弹弓臂是否达到了最大旋转角度,这时就可以进入第二阶段。
在模拟第二阶段时,可以使用ode45来解决弹丸在空中飞行的运动方程。在这个过程中,弹丸受到重力和空气阻力的作用,可以通过设置初始速度和重力加速度来模拟这个过程。当弹丸落地时,可以使用事件检测来检测弹丸是否接触到地面,这时就可以结束模拟过程。
除了模拟弹弓的两个阶段,使用ode45和事件检测还可以解决许多其他多阶段动力学问题。在模拟过程中,还可以使用一些基本的动画和绘图技巧来可视化模拟结果。这些技巧可以帮助我们更好地理解模拟过程,并对模拟结果进行分析和解释。
📚2 运行结果
2.1 运行1
2.2 运行2
2.3 运行3
动态视频:
部分代码:
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% analysis of the flight simulation %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%%%% Check to make sure that the catapult launched
zGroundEvent = solFlight.ye; % state of the system at the instant of launch
if isempty(zGroundEvent)
error('No ground event detected. Invalid parameter set.');
end
%%%% Extract the grid points that ode45 actually used:
tFlightGrid = solFlight.x;
xFlightGrid = solFlight.y(1,:);
yFlightGrid = solFlight.y(2,:);
dxFlightGrid = solFlight.y(3,:);
dyFlightGrid = solFlight.y(4,:);
%%%% Interpolat solution between grid-points
tFlight = linspace(tFlightGrid(1), tFlightGrid(end), 150); %time grid for plotting results
zFlight = deval(solFlight,tFlight); % state at each grid point in time
xFlight = zFlight(1,:);
yFlight = zFlight(2,:);
dxFlight = zFlight(3,:);
dyFlight = zFlight(4,:);
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% Compute full-state across simulation %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% zFull = [x;y;q;dx;dy;dq]
%%%% Compute projectile state during launch:
zTmp = getProjectileState(zLaunch, param);
xLaunch = zTmp(1,:);
yLaunch = zTmp(2,:);
dxLaunch = zTmp(3,:);
dyLaunch = zTmp(4,:);
%%%% Catapult state during flight (constant, at hard stop)
qFlight = qLaunch(end)*ones(size(tFlight));
dqFlight = zeros(size(tFlight));
%%%% Pack everything up:
tFull = [tLaunch, tFlight];
qFull = [qLaunch, qFlight];
xFull = [xLaunch, xFlight];
yFull = [yLaunch, yFlight];
dxFull = [dqLaunch, dqFlight];
dyFull = [dxLaunch, dxFlight];
dqFull = [dyLaunch, dyFlight];
zFull = [xFull;yFull;qFull;dxFull;dyFull;dqFull];
%% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
% Animation of the catapult simulation %
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
figure(4); clf; hold on;
% Colors and markers
lineWidth = 2;
lineColor = [0.2, 0.2, 0.8]; % Blue
markerColor = [0.8,0.2,0.2]; % Red
groundWidth = 5;
groundColor = [77,38,0]/255; % Brown
% Get the scaling for the graphics
xBnd = [min(xFull), max(xFull)] + 0.2*[-1,1]*range(xFull);
xGround = linspace(xBnd(1), xBnd(2), 150);
yGround = groundModel(xGround);
yAll = [yFull,yGround]; %Collect all y points, used for scaling only
yBnd = [min(yAll), max(yAll)] + 0.1*[-1,1]*range(yAll);
% Plot some pine trees for fun
xTree = 2.5*[0.8, 1.9, 2.8, 4.2, 8.2];
hTree = 3.5*[0.8, 1.3, 1.0, 0.7, 1.2];
for i=1:length(xTree)
drawPineTree(xTree(i),groundModel(xTree(i)), hTree(i));
end
% Plot curves
hGnd = plot(xGround, yGround,...
'LineWidth',groundWidth,'Color',groundColor);
hTraj = plot(xFull,yFull,...
'LineWidth',lineWidth,'Color',lineColor);
🎉3 参考文献
文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。
[1]郭洋洲.多阶段气固反应分析仪的研制及焦炭反应动力学实验研究[D].哈尔滨工业大学,2016.DOI:10.7666/d.D01332045.
[2]王子旭.求解动力学多过程问题的策略[J].中学生数理化:高一使用, 2017(1):2.
[3]肖贵膑,代伟,段晨靓,等.例谈用动力学和能量观点解决多过程问题及备考建议[J].中学物理, 2016(11):3.DOI:10.3969/j.issn.1008-4134(g).2016.11.022.