Search code examples
modelicadymola

Discretizing time derivative terms of PDE in the Modelica model


I am trying to use Modelica to discretize a PDE model, but I got stuck with how to discretize the time derivative terms.
As the following screenshot shows, it is a typical method for the heat conduction PDE model, which uses the der operator instead of discretizing the time derivative terms. enter image description here enter image description here

What I am trying to do is discretizing all the derivative terms in the equation, including the time derivative, but I am not sure how to express Q(t+Δt)-Q(t), cause I don't know if there is a mechanism in Modelica that allows me to use the values of a variable of different time points.

My question is:
Is it possible to do discretization on the time derivative terms?

enter image description here


Solution

  • There is no simple support for it.

    A simple possibility is to use der(Q)=(Q(t+Δt)-Q(t))/Δt; which basically gives the method-of-lines, https://en.wikipedia.org/wiki/Method_of_lines

    To use that you have to rewrite the equations from Q(t+Δt)-Q(t)=-uΔt/Δx(Q(t,i+1)-Q(t,i)) to (Q(t+Δt)-Q(t))/Δt=-u(Q(t,i+1)-Q(t,i))//Δx, and replace left-hand-side by der(Q) and use a normal discretization in the x-direction.

    If you really want it exactly discretized like in the text:

    • Do as above and use Euler with the specific step-size as integration method (or in more advanced cases use synchronous with solverMethod="ExplicitEuler").
    • Manually write when sample(Δt,Δt) then Q=pre(Q)+Δt/Δx*...