r - 使用 ggplot 对 pde 有限差分法进行动画处理
问题描述
我有一个功能:
NLUpwindBurgers = function(Nx,Nt,t_end){
Nx = Nx+1
xmax = 1
xmin = 0
h = (xmax-xmin)/(Nx-1)
x = seq(xmin,xmax,by = h)
U = exp(-10*(4*x-1)^2)
dt = 1/Nt
t = 0
while (t <= t_end){
v = dt/h
t = t+dt
Un = U
Um = shift(Un,1)
Up = shift(Un,-1)
F_plus = 1/2 * (Up + Un)
F_minus = 1/2 * (Un + Um)
U= Un-1/2*v*(F_minus+F_minus)*(Un-Um)- 1/2 * v * (F_plus - F_plus) * (Up-Un)}
plot(x,U,type = "l")}
NLUpwindBurgers(100,100,0.0)
NLUpwindBurgers(100,100,0.1)
我想为时间演化的函数设置动画,比如从 t0 =0 到 t_{n}=1。但是阅读 gganimate 我无法弄清楚我该怎么做?有什么帮助吗?
解决方案
推荐阅读
- php - 即使被选中,我的查询也不输出我想要的列
- object-detection - 我使用自己的数据训练了 Yolo v3,但预测显示我没有训练过的课程
- php - MySQL - 主键的重复条目(但实际上不是......)
- c - 为外部 C 库分配不透明缓冲区的正确 Rust 方法是什么?
- web-services - 如何使用 FedEx 网络服务创建运输标签?
- angular - 如果用户登录到该站点,是否想从 chrome 扩展程序中检查?
- ruby - 覆盖用#define_singleton_method 定义的实例方法并调用原始方法
- excel - 无法使用vba将图片从excel发送到电子邮件
- python - 如何根据周数据计算几个月的 SMA?
- java - 我如何从这个 api 解析这个视频 url 并在我的应用程序上播放?android中是否有像Picasso(用于图像)这样的库?