Mathematica 2D热方程动画

编程入门 行业动态 更新时间:2024-10-18 10:34:01
本文介绍了Mathematica 2D热方程动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在二维上绘制温度梯度,并且遇到了很多麻烦。我当前的方法是定义一个插值函数,然后尝试对其进行多次绘制,然后为该图表表添加动画。到目前为止,这是我的信息:

I'm working on mapping a temperature gradient in two dimensions and having a lot of trouble. My current approach is to define an Interpolating Function and then try to graph it a lot of times, then animate that table of graphs. Here's what I have so far:

RT = 388.726919 R = 1 FUNC == NDSolve[{D[T[x, y, t], t] == RT*(D[T[x, y, t], x, x] + D[T[x, y, t], y, y]), T[x, y, 0] == 0, T[0, y, t] == R*t, T[9, y, t] == R*t, T[x, 0, t] == R*t, T[x, 9, t] == R*t}, T, {x, 0, 9}, {y, 0, 9}, {t, 0, 6}]

因此,前两个变量仅控制变化率。我正在求解的方程是基本的2D热方程,其中dT / dt = a(d ^ 2T / dx ^ 2 + d ^ 2T / dy ^ 2)。初始条件将所有内容设置为0,然后将边缘定义为热量变化的来源。现在,它从t = 0到t = 6遍历9x9块。

So the first two variables just control the rate of change. The equation I'm solving is the basic 2D heat equation, where dT/dt=a(d^2T/dx^2+d^2T/dy^2). The initial conditions set everything to 0, then define the edges as the source of the heat change. Right now it sweeps over a 9x9 block from t=0 to t=6.

第二部分尝试使功能正常工作。

The second part attempts to animate the function working.

ListAnimate[ Table[ DensityPlot[T[x, y, t] /. FUNC, {x, 0, 9}, {y, 0, 9}, Mesh -> 9] , {t, 0, 6}] ]

不幸的是,这是行不通的,而我正疯狂地试图找出原因。我最初以为它与插值函数有关,但是现在我对动画代码也没有把握。有人有什么想法吗?

Unfortunately, this doesn't work, and I'm going crazy trying to figure out why. I first thought it had something to do with the Interpolating Function but now I'm not so confident that the animating code works either. Anyone have any ideas?

推荐答案

快速检查一下:

RT = 1 R = 1 FUNC = NDSolve[{D[T[x, y, t], t] == RT*(D[T[x, y, t], x, x] + D[T[x, y, t], y, y]), T[x, y, 0] == 0, T[0, y, t] == R*t, T[9, y, t] == R*t, T[x, 0, t] == R*t, T[x, 9, t] == R*t}, T, {x, 0, 9}, {y, 0, 9}, {t, 0, 6}]; a = Table[ Plot3D[T[x, y, t] /. FUNC, {x, 0, 9}, {y, 0, 9}, Mesh -> 15, PlotRange -> {{0, 9}, {0, 9}, {-1, 10}}, ColorFunction -> Function[{x, y, z}, Hue[.3 (1 - z)]]], {t, 0, 6}] Export["c:\anim.gif", a]

PS:通过使用小写字母作为符号的第一个字符,可以避免很多错误...

PS: A lot of mistakes are avoided by using a lowercase letter as the first char for your symbols...

更多推荐

Mathematica 2D热方程动画

本文发布于:2023-06-03 12:19:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/473804.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方程   动画   Mathematica

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!