Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#1481 closed enhancement (fixed)

Support for the smooth() operator

Reported by: Jesper Mattsson Owned by: Jesper Mattsson
Priority: major Milestone: 1.10.x
Component: Modelica/FrontEnd Version: trunk
Keywords: #664. Cc:

Description

Support the smooth() operator, see p. 26 in MLS 3.2 and adding subclass of FExp. The smooth() operator needs to be at least partially implemented to be able to flatten parts of the MSL.

This is a part of #664.

Change History (8)

comment:1 Changed 8 years ago by hubertus

A simple plan to support smooth() needs to take care of 2 issues:

  1. How to handle events
  2. Differentiation of smooth(n, expr), where n is the degree for which the user promises that the expression inside smooth() is C-n continuous.

Events can be handled as follows:

  • smooth(n, expr) does not generate events for all n >= 1
  • smooth(0, expr) does generate events as ususal for all event-causing subexpressions inside expr in the normal way.
  • If the user wants to suppress events even for smooth(0, expr), they have to write smooth(0,noEvent(expr)), which is fully according to the Modelica specification
  • A more refined handling of events for smooth() could be introduced later, but the above way is safe for simulation and optimization.

Differentiation for index reduction is done as follows

  • smooth(n, expr) is differentiated to smooth(n-1, der(expr)), where der() is w.r.t. time

Differentiation for AD

  • For differentiation of smooth() with respect to other variables than time, nothing is said, so I would simply remove smooth() for the generated code

Comments are welcome.

comment:2 Changed 8 years ago by hubertus

For code generation for optimization smooth(0,expr), code generation should fail unless there is a noEvent() introduced explicitly around expr.

comment:3 Changed 8 years ago by Jesper Mattsson

The spec states that "[...] all partial derivatives with respect to all appearing real variables exist and are continous up to order [´n´]." Doesn't that mean that for differentiation of smooth() with respect to other variables than time, the same as for time applies?

comment:4 Changed 8 years ago by Jesper Mattsson

changeset:2715

Added front-end support for smooth(), including symbolic differentiation and simple test.

Still needs:

  • to be included in the event handling (as specified above)
  • more tests
  • check that the order (n above) is a constant (or parameter?)

comment:5 Changed 7 years ago by jakesson

Resolution: fixed
Status: newclosed

changeset:4537:

-Added support for correct event generation for the smooth operator, see #1481

  • Made the HTML diagnostics clearer for event generating functions, see #2650

The following semantics is implemented according to Hubertus' suggestion:

  • smooth(n, expr) does not generate events for all n >= 1
  • smooth(0, expr) does generate events as ususal for all event-causing subexpressions inside expr in the normal way

comment:6 Changed 7 years ago by jakesson

Milestone: Future1.10.x

comment:7 Changed 5 years ago by Jesper Mattsson

Keywords: #664 added

comment:8 Changed 5 years ago by Jesper Mattsson

Keywords: #664. added; #664 removed
Note: See TracTickets for help on using tickets.