Currently Modelica cannot handle partial differential equations directly since there is only the notion of differentiation with respect to time built into the language. However, in many cases derivatives with respect to other variables such as for example spatial dimensions can be handled by simple discretizations schemes represented using the array capabilities in Modelica. Here we will give an example of how the one dimensional wave equation can be represented in Modelica and how OpenModelica can be used for simulation and display of the results, as well as representing the result as a 2D interpolating function.
Here we are using a Modelica function initialPressure (defined further below) to specify the initial value of the pressure along the duct. The initial pressure profile of the duct.The function initialPressure returns the initial pressure profile function in discretized form as an array.
We simulate the WaveEquationSample model...