Skip to content

Commit

Permalink
PDEModelica documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jansilar authored and adeas31 committed Feb 21, 2018
1 parent 44ab60f commit b7906fe
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions UsersGuide/source/index.rst
Expand Up @@ -27,6 +27,7 @@ Generated on |date| at |time|
omsimulator
optimization
parametersensitivity
pdemodelica
mdt
mdtdebugger
profiler
Expand Down
4 changes: 4 additions & 0 deletions UsersGuide/source/omedit.rst
Expand Up @@ -504,6 +504,8 @@ windows by clicking on the New Plot Parametric toolbar button (|parametric-plot-
:alt: OMEdit New Parametric Plot Window Icon
:height: 14pt

.. _array-plot :

Array Plot
^^^^^^^^^^

Expand All @@ -518,6 +520,8 @@ A new Array Plot window is opened using the New Array Plot Window toolbar button
:alt: OMEdit New Array Plot Window Icon
:height: 14pt

.. _array-parametric-plot :

Array Parametric Plot
^^^^^^^^^^^^^^^^^^^^^

Expand Down
75 changes: 75 additions & 0 deletions UsersGuide/source/pdemodelica.rst
@@ -0,0 +1,75 @@
PDEModelica1
============

PDEModelica1 is nonstandardised experimental Modelica language extension for 1-dimensional partial differential extensions (PDE).

It is enabled using compiler flag ``--grammar=PDEModelica``. Compiler flags may be set e.g. in OMEdit (Tools->Options->Simulation->OMC Flags) or in the OpenModelica script using command

.. omc-mos ::
setCommandLineOptions("--grammar=PDEModelica")
PDEModelica1 language elements
------------------------------

Let us introduce new PDEModelica1 language elements by an advection equation example model:


.. omc-loadstring ::
model Advection "advection equation"
parameter Real pi = Modelica.Constants.pi;
parameter DomainLineSegment1D omega(L = 1, N = 100) "domain";
field Real u(domain = omega) "field";
initial equation
u = sin(2*pi*omega.x) "IC";
equation
der(u) + pder(u,x) = 0 indomain omega "PDE";
u = 0 indomain omega.left "BC";
u = extrapolateField(u) indomain omega.right "extrapolation";
end Advection;
The domain ``omega`` represents the geometrical domain where the PDE holds. The domain is
defined using the built-in record ``DomainLineSegment1D``. This record contains among
others ``L`` – the length of the domain, ``N`` – the number of grid points, ``x`` –
the coordinate variable and the regions ``left``, ``right`` and ``interior``, representing
the left and right boundaries and the interior of the domain.

The field variable ``u`` is defined using a new keyword ``field``. The ``domain``
is a mandatory attribute to specify the domain of the field.

The ``indomain`` operator specifies where the equation containing the field variable holds. It
is utilised in the initial conditions (IC) of the fields, in the PDE and in the boundary
conditions (BC). The syntax is

| ``anEquation indomain aDomain.aRegion;``
If the region is omitted, ``interior`` is the default (e.g. the PDE in the example above).

The IC of the field variable u is written using an expression containing the coordinate
variable ``omega.x``.

The PDE contains a partial space derivative written using the ``pder`` operator. Also
the second derivative is allowed (not in this example), the syntax is e.g. ``pder(u,x,x)``.
It is not necessary to specify the domain of coordinate in pder (to write e.g. ``pder(u,omega.x)``, even though ``x`` is a member of ``omega``.

Limitations
-----------

BCs may be written only in terms of variables that are spatially differentiated currently.

All fields that are spatially differentiated must have either BC or extrapolation at each
boundary. This extrapolation should be done automatically by the compiler, but this has
not been implemented yet. The current workaround is the usage of the ``extrapolateField()``
operator directly in the model.

If-equations are not spported yet, if-expressions must be used instead.

Viewing results
---------------

During translation field variables are replaced with arrays. These arrays may be plotted using :ref:`array-plot` or even better using :ref:`array-parametric-plot` (to plot x-coordinate versus a field).



.. omc-reset ::

0 comments on commit b7906fe

Please sign in to comment.