解决9耦合PDE系统时如何减少内存使用量

时间:2016-05-10 15:12:12

标签: memory wolfram-mathematica physics pde

我有一个耦合偏微分方程组,如1所示。

system of equations

如果按分量写出方程式,则得到9个方程式。 为简单起见,可以将$ \ rho $和$ h $设置为常量。

我将方程式放入mathematica笔记本并使用'NDSolve'。 我在系统中计算了268个衍生品。但是,我没有找到87个以上的条件。

当我运行笔记本时,我收到消息

NDSolve::pdord: Some of the functions have zero differential order, so the equations will be solved as a system of differential-algebraic equations. >>

LinearSolve::sing: Matrix SparseArray[Automatic,<<3>>] is singular. >>

NDSolve::mconly: For the method IDA, only machine real code is available. Unable to continue with complex values or beyond floating-point exceptions. >>

我理解第一个错误:$ \ phi $中没有时间导数,所以系统严格来说是一个微分代数系统。

大约40分钟后,mathematica说:

No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.

我可以改变什么来降低内存成本,或者 - 更好 - 我可以改变哪些来解决系统更优雅?

这是mathematica代码:

NDSolve[{
  eqn1 == 0,
  eqn2 == 0,
  eqn3 == 0,
  eqn4 == 0,
  eqn5 == 0,
  eqn6 == 0,
  eqn7 == 0,
  eqn8 == 0,
  eqn9 == 0,

  (*Initial Conditions*)
  T[0, x, y, z] == 300,
  p[0, x, y, z] == 101300,
  phi[t, x, y, z] == 75 x /. t -> 0,
  u1[0, x, y, z] == 0,
  (*   ect...   *)

  (*BOUNDARY CONDITIONS*)
  phi[t, x, y, z] == 0 /. x -> 0,
  phi[t, x, y, z] == 750 /. x -> 10,
  phi[t, x, y, z] == 75 x /. y -> 0,
  phi[t, x, y, z] == 75 x /. y -> 10,
  phi[t, x, y, z] == 75 x /. z -> 0,
  phi[t, x, y, z] == 75 x /. z -> 10,
  \!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(phi[t, x, y, z]\)\) == 0 /. 
   y -> 0,
  \!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(phi[t, x, y, z]\)\) == 0 /. 
   y -> 10,
  (*  ect.....  *)

  },
 {p, u1, u2, u3, T, phi, a1, a2, a3},
 {t, 0, 10}, {x, 0, 10}, {y, 0, 10}, {z, 0, 10}
 ]

以下是方程式的Latex代码:

\begin{align}   
        %%% first
        \frac{\partial \rho}{\partial t}  + \vec{u} \cdot \nabla \rho + \rho \nabla \cdot \vec{u} &=0 \\
        %%% second
        \rho \frac{\partial \vec{u}}{\partial t} 
        + \rho \vec{u} \cdot \nabla \vec{u} \pm \nabla p 
        + \nabla \cdot \left[- \mu \left( \nabla \vec{u} + \nabla \vec{u}^t \right) \right] \nonumber
        \\ - 
        \left[ \sigma   
        \left( - \nabla \phi - \frac{\partial \vec{A}}{\partial t} \right)
        + \vec{u} \times (\nabla \times \vec{A}) \right]
        %
         \times \left[ \nabla \times \vec{A} \right]
        &= \vec{0} \\
         %%% third
        \rho \frac{\partial h}{\partial t}
        + \rho \vec{u} \cdot \nabla h
        + \nabla \cdot \nabla T
        - \frac{\partial p}{\partial t}
        - \overset{.}{Q_j} + \overset{.}{Q_r}
        &= 0 \\
        %%% fourth
        \nabla \cdot \left[ \sigma  
        \left( - \nabla \phi - \frac{\partial \vec{A}}{\partial t} \right)
         + \vec{u} \times (\nabla \times \vec{A}) \right] &= 0 \\
        %%% fifth
        \frac{\partial \vec{A}}{\partial t} + \nabla \phi - \vec{u} \times \nabla \times \vec{A} - \eta \nabla ^2 \vec{A} &= \vec{0}
    \end{align}

我在这里添加了简单的mathematica代码:

Needs["NDSolve`FEM`"]


kB = N[ 8.6*10^-5 ];
AG = N[1.2*10^6 ];
mu0 = 1.257*10^(-6);

sigma = N[20.];
eta = 1/(mu0 * sigma); 
rho = N[1.];
h = N[1672000.];


r = 1/ 287.058 ;

mu = N[1.];

kappah = N[5.];

cp = N[2.4];



lbb = NDSolve[{
   0 == D[rho, t] + u1[t, x, y, z]*D[rho, x] + 
     u2[t, x, y, z]*D[rho, y] + u3[t, x, y, z]*D[rho, z] + 

     rho*(D[u1[t, x, y, z], x] + D[u2[t, x, y, z], y] + 
        D[u3[t, x, y, z], z]), 

       0 == 
    rho*D[u1[t, x, y, z], t] + 
     rho*u1[t, x, y, z]*D[u1[t, x, y, z], x] - D[p[t, x, y, z], x] - 
     mu*D[D[u1[t, x, y, z], x], x] - 
           mu*D[D[u1[t, x, y, z], y], y] - 
     mu*D[D[u1[t, x, y, z], z], z] - 
           (((-sigma)*D[phi[t, x, y, z], y] - 
          sigma*D[a2[t, x, y, z], t] + 
          u3[t, x, y, 
            z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 

          u1[t, x, y, 
            z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]))*(D[
           a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 
              ((-sigma)*D[phi[t, x, y, z], z] - 
          sigma*D[a3[t, x, y, z], t] + 
          u1[t, x, y, 
            z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 

          u2[t, x, y, 
            z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]))*(D[
           a1[t, x, y, z], z] - D[a3[t, x, y, z], x])), 

       0 == 
    rho*D[u2[t, x, y, z], t] + 
     rho*u2[t, x, y, z]*D[u2[t, x, y, z], y] - D[p[t, x, y, z], y] - 
     mu*D[D[u2[t, x, y, z], x], x] - 
           mu*D[D[u2[t, x, y, z], y], y] - 
     mu*D[D[u2[t, x, y, z], z], z] - 
           (((-sigma)*D[phi[t, x, y, z], z] - 
          sigma*D[a3[t, x, y, z], t] + 
          u1[t, x, y, 
            z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 

          u2[t, x, y, 
            z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]))*(D[
           a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 
              (D[a2[t, x, y, z], x] - 
          D[a1[t, x, y, z], y])*((-sigma)*D[phi[t, x, y, z], x] - 
          sigma*D[a1[t, x, y, z], t] + 


          u2[t, x, y, 
            z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 
          u3[t, x, y, 
            z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]))),

       0 == 
    rho*D[u3[t, x, y, z], t] + 
     rho*u3[t, x, y, z]*D[u3[t, x, y, z], z] - D[p[t, x, y, z], z] - 
     mu*D[D[u3[t, x, y, z], x], x] - 
           mu*D[D[u3[t, x, y, z], y], y] - 
     mu*D[D[u3[t, x, y, z], z], z] - 
           (((-sigma)*D[phi[t, x, y, z], x] - 
          sigma*D[a1[t, x, y, z], t] + 
          u2[t, x, y, 
            z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 

          u3[t, x, y, 
            z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]))*(D[
           a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 
              ((-sigma)*D[phi[t, x, y, z], y] - 
          sigma*D[a2[t, x, y, z], t] + 
          u3[t, x, y, 
            z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 

          u1[t, x, y, 
            z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]))*(D[
           a3[t, x, y, z], y] - D[a2[t, x, y, z], z])), 


      0 == rho*D[h, t] + 
     rho*(u1[t, x, y, z]*D[h, x] + u2[t, x, y, z]*D[h, y] + 
        u3[t, x, y, z]*D[h, z]) + 

     kappah*(D[T[t, x, y, z], x, x] + D[D[T[t, x, y, z], y], y] + 
        D[D[T[t, x, y, z], z], z]) - D[p[t, x, y, z], t], 


      0 == D[
      sigma*(-D[phi[t, x, y, z], x] - D[a1[t, x, y, z], t]) + 
       u2[t, x, y, z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 

       u3[t, x, y, z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]), 
      x] + D[sigma*(-D[phi[t, x, y, z], y] - D[a2[t, x, y, z], t]) + 

       u3[t, x, y, z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 
       u1[t, x, y, z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]), 
      y] + 

     D[sigma*(-D[phi[t, x, y, z], z] - D[a3[t, x, y, z], t]) + 
       u1[t, x, y, z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 

       u2[t, x, y, z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]), 
      z], 

       0 == 
    D[a1[t, x, y, z], t] + D[phi[t, x, y, z], x] - 
     u2[t, x, y, z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 

     u3[t, x, y, z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 
     eta*D[D[a1[t, x, y, z], x], x], 

       0 == 
    D[a2[t, x, y, z], t] + D[phi[t, x, y, z], y] - 
     u3[t, x, y, z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 

     u1[t, x, y, z]*(D[a2[t, x, y, z], x] - D[a1[t, x, y, z], y]) - 
     eta*D[D[a2[t, x, y, z], y], y], 

       0 == 
    D[a3[t, x, y, z], t] + D[phi[t, x, y, z], z] - 
     u1[t, x, y, z]*(D[a1[t, x, y, z], z] - D[a3[t, x, y, z], x]) - 

     u2[t, x, y, z]*(D[a3[t, x, y, z], y] - D[a2[t, x, y, z], z]) - 
     eta*D[D[a3[t, x, y, z], z], z], T[0, x, y, z] == 300, 



   p[0, x, y, z] == 101300, 
   phi[t, x, y, z] == 75*x /. t -> 0, u1[0, x, y, z] == 0,
   u2[0, x, y, z] == 0, u3[0, x, y, z] == 0,
   a1[0, x, y, z] == 0, a2[0, x, y, z] == 0,
   a3[0, x, y, z] == 0, D[T[t, x, y, z], x] == 0 /. x -> 0,

   D[T[t, x, y, z], x] == 0 /. x -> 10, 
   D[T[t, x, y, z], y] == 0 /. y -> 0,
   D[T[t, x, y, z], y] == 0 /. y -> 10,
   D[T[t, x, y, z], z] == 0 /. z -> 0, 
   D[T[t, x, y, z], z] == 0 /. z -> 10,

   phi[t, x, y, z] == 0 /. x -> 0,
   phi[t, x, y, z] == 750 /. x -> 10,
   phi[t, x, y, z] == 75*x /. y -> 0, 
   phi[t, x, y, z] == 75*x /. y -> 10,
   phi[t, x, y, z] == 75*x /. z -> 0,
   phi[t, x, y, z] == 75*x /. z -> 10, 
   D[phi[t, 0, y, z], x] == (-sigma^(-1))*0.5*AG*T[t, 0, y, z]^2*
     Exp[-4/(kB*T[t, 0, y, z])],
   D[phi[t, 10, y, z], x] == (-sigma^(-1))*0.5*AG*T[t, 10, y, z]^2*
    Exp[-4/(kB*T[t, 10, y, z])],
   D[phi[t, x, y, z], y] == 0 /. y -> 0, 
   D[phi[t, x, y, z], y] == 0 /. y -> 10, 
   D[phi[t, x, y, z], z] == 0 /. z -> 0, 
   D[phi[t, x, y, z], z] == 0 /. z -> 10, 

   p[t, x, y, z] == 101300 /. x -> 0,
   p[t, x, y, z] == 101300 /. x -> 10,
   p[t, x, y, z] == 101300 /. y -> 0,
   p[t, x, y, z] == 101300 /. y -> 10, 
   p[t, x, y, z] == 101300 /. z -> 0, 
   p[t, x, y, z] == 101300 /. z -> 10, u1[t, x, y, z] == 0 /. x -> 0, 
   u1[t, x, y, z] == 0 /. x -> 10, 

   D[u1[t, x, y, z], y] == 0 /. y -> 0,
   D[u1[t, x, y, z], y] == 0 /. y -> 10,
   D[u1[t, x, y, z], z] == 0 /. z -> 0, 
   D[u1[t, x, y, z], z] == 0 /. z -> 10,

   u2[t, x, y, z] == 0 /. x -> 0, 
   u2[t, x, y, z] == 0 /. x -> 10,
   D[u2[t, x, y, z], y] == 0 /. y -> 0, 
   D[u2[t, x, y, z], y] == 0 /. y -> 10,
   D[u2[t, x, y, z], z] == 0 /. z -> 0,
   D[u2[t, x, y, z], z] == 0 /. z -> 10, 

   u3[t, x, y, z] == 0 /. x -> 0, u3[t, x, y, z] == 0 /. x -> 10,
   D[u3[t, x, y, z], y] == 0 /. y -> 0,
   D[u3[t, x, y, z], y] == 0 /. y -> 10, 
   D[u3[t, x, y, z], z] == 0 /. z -> 0,
   D[u3[t, x, y, z], z] == 0 /. z -> 10,

   a1[t, x, y, z] == 0 /. x -> 0, 
   a1[t, x, y, z] == 0 /. x -> 10, 
   a1[t, x, y, z] == 0 /. y -> 0, 
   a1[t, x, y, z] == 0 /. y -> 10, 
   a1[t, x, y, z] == 0 /. z -> 0, 
   a1[t, x, y, z] == 0 /. z -> 10, 
   D[a1[t, x, y, z], x] == 0 /. x -> 0, 
   D[a1[t, x, y, z], x] == 0 /. x -> 10, 
   D[a1[t, x, y, z], y] == 0 /. y -> 0, 
   D[a1[t, x, y, z], y] == 0 /. y -> 10, 
   D[a1[t, x, y, z], z] == 0 /. z -> 0, 
   D[a1[t, x, y, z], z] == 0 /. z -> 10, 

   a2[t, x, y, z] == 0 /. x -> 0, 
   a2[t, x, y, z] == 0 /. x -> 10, 
   a2[t, x, y, z] == 0 /. y -> 0, 
   a2[t, x, y, z] == 0 /. y -> 10, 
   a2[t, x, y, z] == 0 /. z -> 0, 
   a2[t, x, y, z] == 0 /. z -> 10, 
   D[a2[t, x, y, z], x] == 0 /. x -> 0, 
   D[a2[t, x, y, z], x] == 0 /. x -> 10, 
   D[a2[t, x, y, z], y] == 0 /. y -> 0, 
   D[a2[t, x, y, z], y] == 0 /. y -> 10, 
   D[a2[t, x, y, z], z] == 0 /. z -> 0, 
   D[a2[t, x, y, z], z] == 0 /. z -> 10, 

   a3[t, x, y, z] == 0 /. x -> 0, 
   a3[t, x, y, z] == 0 /. x -> 10, 
   a3[t, x, y, z] == 0 /. y -> 0, 
   a3[t, x, y, z] == 0 /. y -> 10, 
   a3[t, x, y, z] == 0 /. z -> 0, 
   a3[t, x, y, z] == 0 /. z -> 10, 
   D[a3[t, x, y, z], x] == 0 /. x -> 0, 
   D[a3[t, x, y, z], x] == 0 /. x -> 10, 
   D[a3[t, x, y, z], y] == 0 /. y -> 0, 
   D[a3[t, x, y, z], y] == 0 /. y -> 10, 
   D[a3[t, x, y, z], z] == 0 /. z -> 0, 
   D[a3[t, x, y, z], z] == 0 /. z -> 10

   }, 
  {p, u1, u2, u3, T, phi, a1, a2, a3}, 
  {t, 0, 10}, {x, 0, 10}, {y, 0, 10}, {z, 0, 10}]

非常感谢!

0 个答案:

没有答案