Code Monkey home page Code Monkey logo

bilibili-dg-lectures's People

Contributors

l1ssandra avatar yinliu-91 avatar

Stargazers

 avatar

Forkers

zhqroger

bilibili-dg-lectures's Issues

代码中哪里需要最终的解结果而不是系数

image

  1. 从公式可以看出,有两处需要最终的解结果:
    • 一次计算cell内的积分,即代码中Lh函数的uhG
    • 一次需要计算数值通量,即代码中的Lh函数的uhR,uhL
      上面的几个变量都是真解的结果,不是系数

为何使用L2投影获取初值

  1. 这里说 因为要得到0时刻此时的u在每个单元的基函数的系数c0,然后再对c0进行时间推进。本质上是通过某一时刻u在每个单元的基函数的系数,刻画这个时刻的计算域内u的的分布。
  2. 另外初值即问题的解是一些列多项式的系数,而不是直接的解析解
  3. 可以参考这里https://zhuanlan.zhihu.com/p/605450187

uh的含义和如何计算单元3个点处的结果

uh的含义

  1. uh只是某个单元某个多项式系数的值: $c_0,c_1,c_2$
  2. 而某个单元上最终的结果表示为: $u_h=c_0\phi_0+c_1\phi_1+c_2\phi_2$
  3. 而所以有 $\int_{I_i}f(u_h^n)\phi_xdx$, uhG(i,:)表示的是对于某个单元i,所有积分点处的解的结果(不是系数,是真实的解),固定某个GLP点看,其表达的就是上面2中的叠加
% Step 1: calculate the Integral in cell
for i = 1:Nx                                      % 对所有对单元上的
    for d = 1:dimPk                               % 所有型函数进行计算,并累加到uhG上。进行对是所有型函数对累加
        uhG(i,:) = uhG(i,:) + uh(i,d)*phiG(:,d)'; % 这里计算的是f(u)中的u,下面才是计算的积分
    end
end
  1. 从下面看出,uh程序中只是解的系数,并不是解:
for d = 1:dimPk
    uh(:,d) = uh(:,d)/mm(d);  % mm在get_basis.m中定义, 这里看出,uh只是多项式的系数,并不是解
end

如何计算与保存最后的真解

  1. 由于uh只是系数,所以真解要用上面2中的公式计算

  2. 由于在每个单元中,左中右的点分别为(-1,0,1),所以将其带入2中公式后得到:

    • $u_l=c_0-c_1+\frac{2}{3}\cdot c_2$
    • $u_m=c_0-\frac{1}{3}c_2$
    • $u_r=c_0+c_1+\frac{2}{3}\cdot c_2$
    if(mod(floor(t/dt),nsaveT)==0)
      i=i+1;
      % 在单元[-1,0,1]的三个位置处计算最终的求解变量结果
      saved(i,:,:)=[uh(:,1)-uh(:,2)+2/3*uh(:,3) uh(:,1)-1/3*uh(:,3) uh(:,1)+uh(:,2)+2/3*uh(:,3)];
    end
    
  3. 真解图像为:
    image

  4. 而uh的图像为:
    image

TVD限制器

  1. 参考链接 https://zhuanlan.zhihu.com/p/612189005
  2. 链接中的如下值,是根据 #6 中介绍的公式计算的:
    • $u_l=c_0-c_1+\frac{2}{3}\cdot c_2$

    • $u_m=c_0-\frac{1}{3}c_2$

    • $u_r=c_0+c_1+\frac{2}{3}\cdot c_2$
      image

    • 从chiwang shu 的天元课程讲义中有(注意,均值是对 $uh=c_0+c_1x+c_2(x^2-1/3)$ 在-1,1上积分平均的结果,不是三个点的值简单相加再相除),经过积分后, $\bar{u}_i=c_0$
      image

    • 那么: $u_{i+1/2}-\bar{u}_i=c_0+c_1+\frac{2}{3}\cdot c_2-(c_0)=c_1+2/3c_2$

    • 且: $\bar{u}_{i}-u=c_1-2/3c_2$ 截图中第二项好像不太对?

    • 因此利用下图公式可以得到 $c_1=\frac{minmod_1+minmod_2}{2}, c_2=\frac{3}{4}(minmod_1-minmod_2)$,即如下代码中的uhmod(i,2),uhmod(i,3)

    for i = 1:Nx  % 循环所有单元                                      
    deltaUR = uh(i,2) + (2/3)*uh(i,3);              % 单元右端值减去平均值
    deltaUL = uh(i,2) - (2/3)*uh(i,3);              % 单元平均值减去单元左端值?这里对?
    deltaURM = uhb(i + 2,1) - uhb(i + 1,1);         % 右单元平均值减去本单元平均值
    deltaULM = uhb(i + 1,1) - uhb(i,1);             % 本单元平均值减去左单元平均值
    
    deltaURM1 = minmod(deltaUR,deltaURM,deltaULM);
    deltaULM1 = minmod(deltaUL,deltaURM,deltaULM);
    
    uhmod(i,2) = (deltaURM1 + deltaULM1)/2;
    uhmod(i,3) = 3*(deltaURM1 - deltaULM1)/4;
    end
    
  3. 利用minmod函数求new定义如下(minmod对于输入同号时才有非零值,不同号为0),这时,能根据minmod定义求出下面方程右端项结果:
    image
  4. 将上图左端项与系数的关系求得如下:
    image
    • 上图右端由minmod函数给出,那么此为2个未知量,2个方程,可以求出新的 $c_1,c_2$的结果,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.