【问题标题】:OpenModelica solving a PDE Initialization errorOpenModelica 解决 PDE 初始化错误
【发布时间】:2017-08-04 01:20:07
【问题描述】:

我正在尝试使用 OpenModelica 对边界条件 u(0,t)=t^2 和 u_x(0,t)=0 的非常简单的 PDE du/dx=du/dt 进行数值求解。我已经写了下面的代码:

model pdetest_1

    parameter Real L=1;
    parameter Integer N=100;
    parameter Real dx=L/(N-1);
    parameter Real[N] x=array(i*dx for i in 0:N-1);

    Real u[N],ux[N];

initial equation

    for i in 1:N loop
      u[i]=0;
    end for;

equation
    u[1]=(time)^2;
    ux[1]=0;

    for i in 2:N loop
      u[i]=u[i-1]+dx*ux[i-1];
      der(u[i])=ux[i];
    end for;

end pdetest_1;

它确实可以编译,但是它没有完成模拟退出并出现以下错误:

Blocstdout | OMEditInfo |

C:/Users/.../AppData/Local/Temp/OpenModelica/OMEdit/pdetest_1.exe -port=50450 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance= 1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=pdetest_1_res.mat -jacobian=coloredNumerical -w -lv=LOG_STATS

kquote LOG_INIT |错误 |

由于以下等式,初始化问题不一致:0!= 0.000204061 = u[4]

标准输出 |警告 |

初始化错误。存储结果并退出。
使用 -lv=LOG_INIT -w 了解更多信息。

标准输出 |错误 |

模拟过程失败。以代码 -1 退出。

如果您能帮助我了解问题所在以及如何解决,我将不胜感激?

【问题讨论】:

    标签: modelica pde openmodelica


    【解决方案1】:

    好的,首先很遗憾看到 Modelica 社区对这个话题如此麻木。在 SO 或 OpenModelica 论坛中有十几个与 PDE 相关的问题,没有多少有正确的答案。我决定让this Github repo 收集我在互联网上可以找到的所有相关材料,这样至少其他人不必为一个工作示例而疑惑。

    但是关于上面的代码。代码几乎没问题,问题在于问题的物理性质。 I asked the question in computational science and got a very good answer.

    工作代码是:

    model pdetest_1
      parameter Real L = 1;
      parameter Integer N = 100;
      parameter Real dx = L / (N - 1);
      parameter Real c = 1;
      Real u[N], ux[N];
    initial equation
      for i in 1:N loop
        u[i] = 0;
      end for;
    equation
      if c>0 then
        u[N] = time ^ 2;
        ux[N] = 0;
        for i in 1:N-1 loop
          u[i] = u[i + 1] - dx * ux[i];
          der(u[i]) = c*ux[i];
        end for;
      else
        u[1] = time ^ 2;
        ux[1] = 0;
        for i in 2:N loop
          u[i] = u[i - 1] + dx * ux[i];
          der(u[i]) = c*ux[i];
        end for;
      end if;
    end pdetest_1;
    

    我使用this presentation by Jan Silar 中的代码解决了这个问题。我还提到了the example 4 of the said github repo中的代码。

    【讨论】:

      猜你喜欢
      • 2016-01-11
      • 2017-08-26
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 2017-10-04
      • 2018-02-03
      相关资源
      最近更新 更多