MapleToModelica
 create a Modelica model from Maple input

 Calling Sequence MapleToModelica(sys, opts)

Parameters

 sys - (optional) list or set of equations, a DynamicSystems object, or a string opts - (optional) equation(s) of the form option = value; specify options for MapleToModelica

Options

 • annotation = string
 A Maple string containing the content of a Modelica annotation. It is used to create an annotation for the generated Modelica.
 • class = model or connector
 Specifies whether the Modelica is a model or a connector. The default is model.
 • class_name = string
 The name of the generated Modelica class (model). The default is "custom" with a positive integer appended.
 • comment = string
 A string used to annotate the generated Modelica.
 • display = true or false
 True means print a formatted version of the generated Modelica. The default is false.
 • equations_only = true or false
 True means return only the Modelica initial equations, and equations, as a string.  This is useful for displaying how sys is interpreted as Modelica.
 • flatten = true or false
 True means flatten the Modelica. The default is false.
 • omit_annotations = true or false
 True means omit annotations from the generated Modelica. This may be used with display to view the code without the distraction of the annotations. The default is false.
 • warning_only = true or false
 True means generate a warning, but do not raise an error, if there is a problem with the generated Modelica code. Using this allows the code to be inspected. The default is false.

Interface Options

These options specify the interface between the component equations, sys, and the outside world.

 • append_custom_connectors = truefalse
 True means append any custom connectors assigned by the custom_connectors option to the generated modelica. The default is true.
 • components = list or set
 Specifies Modelica components used in the model. The general form of each element is $\mathrm{id}::\mathrm{type}=\mathrm{modifications}$.
 • constants = list or set
 Specifies the constants, their types, and their values. The format is identical to parameters. Note that because constants is an assigned Maple global name, this keyword must be forward-quoted when used. The default is the empty set.
 • connections or connectors = list or set
 Specifies the connections to the component. The order of the corresponding declarations in the output matches that of the input. A list should be used when using the default pin placement strategy, the order determines the order on an edge. This option is ignored if sys is a DynamicSystems object.
 – Each element of connections specifies the characteristics of one port.
 – The full specification has the form $\mathrm{id}::\mathrm{type}=\mathrm{signals}$, where id is a string that becomes the port name, type specifies the type of connection, and signals specify the Maple expressions connected to the port.
 – The id field is required.  It is a string or name that corresponds to a valid Modelica unquoted identifier.
 • A Modelica flow or stream variable in a connector is designated by wrapping the id with $\mathrm{flow}$ or $\mathrm{stream}$, for example, $\mathrm{flow}\left("i"\right)$.
 – The type field is a Maple name or string that specifies the type of the connection. The type may be omitted. The default is real.
 • The names real, boolean, and integer correspond to the causal Modelica types Real, Boolean, and Integer. The names electrical, fluidheatflow, magnetic, rotational, thermal, and translational correspond to standard Modelica acausal interface ports.
 • Type names may be indexed by a positive integer to indicate the dimension of the connector. For example, electrical[3] specifies an electrical port with dimension three.
 • The type field may be a full Modelica type, or can be an identifier for a custom connector defined via the custom_connectors option.
 – The signals field specifies the Maple expression that is connected to the port.
 • It is optional for causal types. If omitted, the id is used as the connection.
 • An acausal connector type requires a list of Maple expressions, the first being the across-variable (potential), the second the through-variable (flow). For example, for an electric port the signals may be $\left[v\left(t\right),-i\left(t\right)\right]$.
 • A custom connector type also requires a list of Maple expressions, the list corresponds to the signals in the connector.
 • An array type must have a signal field that is a list of expressions, or listlist of expressions.
 – The neutral-operator &c may be used to a attach a comment string to a connection.  For example, p :: electrical = [v(t),i(t)] &c "positive pin" adds the comment string "positive pin" to the Modelica declaration of the p connector.
 • custom_connectors = list or set of equations
 Specifies custom connectors. The left side of the equation is a string or symbol that identifies the connector type. The right side of the equation is a string of Modelica code that defines the connector. For example, MyConn = "connector MyConn input Real u; output Real y; end MyConn;".
 • dont_declare = set of symbols
 Specifies variables that should not be declared. These are variables that are used in the system equations but have been inherited from an extension (see the extends options). The default is an empty set.
 • extends = name, string, or list of such
 Generates Modelica extends clause(s). The value is the class name from which the component is extended. A list may be used to create multiple extends-clauses.
 • import = list
 List of Modelica imports. Each element can be a name or string, or an equation of such.
 • initial = list or set of equations
 Specifies initial equations. Values at the initial time are specified as $x\left(0\right),\mathrm{D}\left(x\right)\left(0\right),{\mathrm{D}}^{\left(2\right)}\left(x\right)\left(0\right)$.
 • parameters = list or set
 Specifies the parameters, their types, and their default values. The order of the corresponding declarations in the output matches that of the input.
 – Each element specifies one parameter.
 – The full specification has the form $\mathrm{id}::\mathrm{type}=\mathrm{value}$
 – The id field is required.  It is a string or symbol that corresponds to a valid Modelica unquoted identifier.  It should match the Maple symbol used in the eqs.
 • A Modelica protected parameter is indicated by wrapping the id with $\mathrm{protected}$; for example, $\mathrm{protected}\left("K"\right)$. A Modelica public parameter is indicated in a similar manner, using  $\mathrm{public}$. By default, parameters are public.
 – The optional type field specifies the parameter type. The allowable types are real, boolean, and integer. The default is real.  A type may be indexed with a positive integer to specify an array parameter.
 – The optional value field specifies the start value of the parameter. The value is an algebraic expression, or, if the parameter is an array type, a list of algebraic expressions.
 – The neutral operator &c may be used to attach a comment string to the parameter declaration.  For example, Larm :: real = 3 &c "length of arm" adds the comment string "length of arm" to the Modelica declaration of the parameter Larm.
 • tvar = symbol
 Specifies the independent time variable used in the equations. Used when sys is a set of equations. The default is t.
 • variables = list or set
 Specifies variables, their types, and, optionally, their initial values. The specification and operation is essentially identical to that of the parameters option; see the parameters option in this section for details.

Icon Options

These options specify the component icon and the placement and type of pins on its edge. Component icons are always rectangular.

 • bitmap = string
 Specify a bitmap file to use for the component icon. The bitmap file may have extension bmp, jpg, jpeg, or png. The syntax is that of a URI: a scheme name (file or attachment), followed by a colon, followed by the location.  For example, "file:///home/bob/icons/myicon.png". The attachment scheme is used for bitmap files attached to the MapleSim document. The default is the empty string, which specifies that no bitmap file is used.
 • copy_icon = string or none
 Specifies a Modelica component. The icon of the specified component is used for this component. If none is used, no icon is created. This is useful when extending a model that assigns the icon. The default icon is "Maplesoft.Icons.CustomComponent".
 • filled_pins = list or set of strings
 Specifies which connection icons are filled (solid). The keyword input_pins is a synonym. By convention, the inputs of causal connections are filled, the outputs are unfilled. The strings correspond to the connection names (see the connections option in the Interface Options section). By default all connections are filled, though connections generated automatically from a DynamicSystems object get the proper convention. See also unfilled_pins.
 • icon_graphics = list of strings
 The strings are Modelica graphical annotations; they are combined with the existing graphical annotations of the icon. This can be used to add some small detail to an existing icon, say a line for an added connection. The default is an empty list.
 • icon_size = list of two positive integers
 Specifies the dimensions of the icon in pixels, as $\left[\mathrm{width},\mathrm{height}\right]$. The default is 200 x 200.
 • input_pins = list or set of strings
 A synonym for filled_pins.
 • min_gap = positive integer
 Specifies the minimum gap between pins, when placed automatically. If this cannot be met, the edge dimension is increased, unless icon_size is specified, in which case an error is raised. The default is 10.
 • output_pins = list or set of strings
 A synonym for unfilled_pins.
 • pin_placement = list or set of equations
 Specifies the placement of the connections.
 – The left side of each equation is a name corresponding to an edge, left, right, top, or bottom.
 – The right side of each equation specifies the connections made on the corresponding edge. It is a string, or list of strings. A string must match one of the strings used on the left side of the connection equations (see the connections option in the Interface Options section). If a string, the pin is placed in the center of the edge. If a list, the pins are arranged in that order, from top to bottom, or left to right, depending whether the edge is vertical or horizontal.
 – The default for a DynamicSystems object is to place the inputs on the left and the outputs on the right. Other systems must specify the locations.
 – An alternative syntax is for each equation to have the form $\mathrm{string}=\left[\mathrm{numeric},\mathrm{numeric}\right]$, where the left side is the name of a pin and the right side specifies its location. The locations should lie on the edge of the icon.
 • unfilled_pins = list or set of strings
 Specifies which connection icons are unfilled (open). The keyword output_pins is a synonym. By convention, the inputs of causal connections are filled and the outputs are unfilled. The strings correspond to the connection names (see the connections option in the Interface Options section). By default all connections are filled, however, connections generated automatically from a DynamicSystems object get the proper convention. See also filled_pins.

Description

 • The MapleToModelica command creates a Modelica model from either Maple equations, a DynamicSystems object, or a Modelica class name. It also creates a Modelica connector from a connector specification.
 • The optional sys parameter specifies the system equations. It may be a list or set of differential-algebraic equations, a DynamicSystems object, or a string corresponding to a Modelica class. The default value of sys is an empty set. This is useful when creating a custom connector.
 • When sys is a list or set of equations, the following considerations apply:
 – Variables in the equations should be represented as functions of time, for example, $x\left(t\right)$. The tvar option specifies the time variable, by default t.
 – Time derivatives are expressed as diff(x(t),t).
 – Time derivatives of order greater than one are converted to first-order derivatives using auxiliary variables.
 – Initial conditions are expressed by substituting 0 for the time-variable; for example, $x\left(0\right)=0$. The D operator expresses initial derivatives; for example, $\mathrm{D}\left(x\right)\left(0\right)=1$.
 – Conditional expressions may be represented as piecewise expressions; for example, $\left\{\begin{array}{cc}x\left(t\right)& x\left(t\right). A symbolic expression, say $b\left(t\right)$, in a condition may be expressed as $b\left(t\right)=\mathrm{true}$; piecewise requires a Maple boolean expression.
 – The and, or, and not boolean operators may be used in boolean expressions.
 – The Modelica function noEvent may be applied to an expression to prevent events from being generated by the inequalities of the expression; for example, $\mathrm{noEvent}\left(\left\{\begin{array}{cc}t& t<1\\ {t}^{2}& \mathrm{otherwise}\end{array}\right\\right)$.
 – The following standard Maple functions are handled: sin, cos, tan, arcsin, arccos, arctan, sinh, cosh, tanh, exp, ln, and log; arctan may be used in either the one or two argument form.  The log function is identical to the ln function.
 • When sys is a DynamicSystems object, the inputs and output of the object become the inputs and outputs of the model, respectively. The inputs are placed on the left side of the icon, the outputs on the right. The systemname field of the DynamicSystems object is used as the class name of the model, unless it is the empty string or the class_name parameter is passed to MapleToModelica.
 • When sys is a string corresponding to a fully-qualified Modelica class, the modelica corresponding to the class definition is returned.  This is primarily useful for inspecting the equations of a class to be extended. See the Modelon Hydraulics example.
 • The generated Modelica model is returned as a string.

Examples

Access MapleToModelica directly.

 > $\mathrm{with}\left(\mathrm{MapleSim}:-\mathrm{Tools}\right):$

DynamicSystems

Create a DynamicSystems object and convert it to Modelica.

 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{sys}≔\mathrm{NewSystem}\left(\frac{K}{{s}^{2}+\frac{\mathrm{ω0}}{Q}s+{\mathrm{ω0}}^{2}}\right):$
 > $\mathrm{MapleToModelica}\left(\mathrm{sys},\mathrm{class_name}="second_order",\mathrm{display}\right):$
 model second_order     extends Maplesoft.Icons.CustomComponent;     Modelica.Blocks.Interfaces.RealInput u[1] annotation (Placement(transformation(         extent = {             {-110, -10},             {-90, 10}},         rotation = 0)));     Modelica.Blocks.Interfaces.RealOutput y[1] annotation (Placement(transformation(         extent = {             {90, -10},             {110, 10}},         rotation = 0)));     parameter Real K = 0;     parameter Real Q = 0;     parameter Real omega0 = 0;     Real x[2]; equation     der(x[1]) = -omega0 ^ (-1) * Q * x[2];     der(x[2]) = omega0 ^ 3 / Q * x[1] - omega0 / Q * x[2] - omega0 / Q * u[1];     y[1] = K * x[1]; end second_order;

Create a multi-input, multi-output DynamicSystems object.

 > $\mathrm{sys2}≔\mathrm{NewSystem}\left(⟨⟨\frac{1}{{s}^{2}}|\frac{{s}^{2}}{{s}^{3}+5{s}^{2}+7s+6}⟩,⟨\frac{1}{s}|\frac{c}{{s}^{2}+as+b}⟩⟩\right)$
 ${\mathrm{sys2}}{≔}\left[\begin{array}{c}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({s}\right){,}{\mathrm{u2}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({s}\right){,}{\mathrm{y2}}{}\left({s}\right)\right]\end{array}\right$ (1)

Convert the system to Modelica. Override the default connector names, specify initial values for the state variables, and specify the default values for the parameters a, b, and c.

 > $\mathrm{MapleToModelica}\left(\mathrm{sys2},\mathrm{connectors}=\left["inp"::\mathrm{real}\left[2\right]=\left[u\left[1\right],u\left[2\right]\right]\left(t\right),"out"::\mathrm{real}\left[2\right]=\left[y\left[1\right],y\left[2\right]\right]\left(t\right)\right],\mathrm{initial}=\left[x=\left[0,0,0,0,0,0,0\right]\right],\mathrm{class_name}="MIMO",\mathrm{output_pins}=\left["out"\right],\mathrm{parameters}=\left[a=1,b=2,c=\mathrm{\pi }\right],\mathrm{display}\right):$
 model MIMO     extends Maplesoft.Icons.CustomComponent;     Modelica.Blocks.Interfaces.RealInput inp[2] annotation (Placement(transformation(         extent = {             {-110, -10},             {-90, 10}},         rotation = 0)));     Modelica.Blocks.Interfaces.RealOutput out[2] annotation (Placement(transformation(         extent = {             {90, -10},             {110, 10}},         rotation = 0)));     parameter Real a = 1;     parameter Real b = 2;     parameter Real c = Modelica.Constants.pi;     Real x[7];     Real u[2];     Real y[2]; initial equation     x = {0, 0, 0, 0, 0, 0, 0}; equation     der(x[1]) = x[2];     der(x[2]) = u[1];     der(x[3]) = x[4];     der(x[4]) = x[5];     der(x[5]) = x[6];     der(x[6]) = (-5 - a) ^ (-1) * x[7];     der(x[7]) = -6 * b * (-5 - a) * x[3] + (-6 * a - 7 * b) * (-5 - a) * x[4] + (-6 - 7 * a - 5 * b) * (-5 - a) * x[5] + (-7 - 5 * a - b) * (-5 - a) * x[6] + (-5 - a) * x[7] + (-5 - a) * u[2];     y[1] = x[1] + b * x[5] + a * x[6] + (-5 - a) ^ (-1) * x[7];     y[2] = x[2] + 6 * c * x[3] + 7 * c * x[4] + 5 * c * x[5] + c * x[6];     inp[1] = u[1];     inp[2] = u[2];     out[1] = y[1];     out[2] = y[2]; end MIMO;

Simple Causal Model

Implement the equation $y=\mathrm{u1}+K\left(\mathrm{v1}+\mathrm{v2}\right)$, with $\mathrm{v1}$ and $\mathrm{v2}$ two components of a vector input.

 > $\mathrm{MapleToModelica}\left(\left\{y\left(t\right)=\mathrm{u1}\left(t\right)+K\left(\mathrm{v1}\left(t\right)+\mathrm{v2}\left(t\right)\right)\right\},\mathrm{class_name}="mymodel",\mathrm{parameters}=\left\{K=1\right\},\mathrm{connections}=\left["u"::\mathrm{real}=\mathrm{u1},"v"::\mathrm{real}\left[2\right]=\left[\mathrm{v1},\mathrm{v2}\right],"y"::\mathrm{real}=y\right],\mathrm{unfilled_pins}=\left\{"y"\right\},\mathrm{omit_annotations},\mathrm{display}\right):$
 model mymodel     extends Maplesoft.Icons.CustomComponent;     Modelica.Blocks.Interfaces.RealInput u;     Modelica.Blocks.Interfaces.RealInput v[2];     Modelica.Blocks.Interfaces.RealOutput y;     parameter Real K = 1;     Real u1;     Real v1;     Real v2; equation     u = u1;     y = u1 + K * (v1 + v2);     v[1] = v1;     v[2] = v2; end mymodel;

Simple Acausal Model

Implement a resistor model with a power variable.

 > $\mathrm{eqs}≔\left\{P\left(t\right)=v\left(t\right)i\left(t\right),v\left(t\right)=Ri\left(t\right),v\left(t\right)=\mathrm{vp}\left(t\right)-\mathrm{vn}\left(t\right)\right\}:$
 > $\mathrm{MapleToModelica}\left(\mathrm{eqs},\mathrm{class_name}="resistor_with_power",\mathrm{import}="Modelica.SIunits.Resistance",\mathrm{parameters}=\left[R::\mathrm{Resistance}=1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"resistance"\right],\mathrm{variables}=\left[P::\mathrm{Power},i::\mathrm{Current},v::\mathrm{Voltage},\mathrm{vn}::\mathrm{Voltage},\mathrm{vp}::\mathrm{Voltage}\right],\mathrm{connections}=\left["p"::\mathrm{electrical}=\left[\mathrm{vp},i\right]\left(t\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"positive pin","n"::\mathrm{electrical}=\left[\mathrm{vn},-i\right]\left(t\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"negative pin"\right],\mathrm{unfilled_pins}=\left\{"n"\right\},\mathrm{omit_annotations},\mathrm{display}\right):$
 model resistor_with_power     import Modelica.SIunits.Resistance;     extends Maplesoft.Icons.CustomComponent;     Modelica.Electrical.Analog.Interfaces.PositivePin p "positive pin";     Modelica.Electrical.Analog.Interfaces.NegativePin n "negative pin";     parameter Modelica.SIunits.Resistance R = 1 "resistance";     Modelica.SIunits.Power P;     Modelica.SIunits.Current i;     Modelica.SIunits.Voltage v;     Modelica.SIunits.Voltage vn;     Modelica.SIunits.Voltage vp; equation     P = v * i;     v = R * i;     v = vp - vn;     n.i = -i;     n.v = vn;     p.i = i;     p.v = vp; end resistor_with_power;

Multiphase Resistor

Create a multiphase resistor with a common value. While one should normally declare all variables, here we use the defaults chosen by MapleToModelica, which is to declare undeclared variables as Real. The declared dimension is the largest index used.

The copy_icon option is used to copy the resistor symbol from an existing component.

 > $\mathrm{num}≔3:$
 > $\mathrm{eqs}≔\left\{\mathrm{seq}\left(\mathrm{op}\left(\left[v\left[k\right]\left(t\right)=Ri\left[k\right]\left(t\right),v\left[k\right]\left(t\right)=\mathrm{vp}\left[k\right]\left(t\right)-\mathrm{vn}\left[k\right]\left(t\right)\right]\right),k=1..\mathrm{num}\right)\right\}$
 ${\mathrm{eqs}}{≔}\left\{{{v}}_{{1}}{}\left({t}\right){=}{R}{}{{i}}_{{1}}{}\left({t}\right){,}{{v}}_{{1}}{}\left({t}\right){=}{{\mathrm{vp}}}_{{1}}{}\left({t}\right){-}{{\mathrm{vn}}}_{{1}}{}\left({t}\right){,}{{v}}_{{2}}{}\left({t}\right){=}{R}{}{{i}}_{{2}}{}\left({t}\right){,}{{v}}_{{2}}{}\left({t}\right){=}{{\mathrm{vp}}}_{{2}}{}\left({t}\right){-}{{\mathrm{vn}}}_{{2}}{}\left({t}\right){,}{{v}}_{{3}}{}\left({t}\right){=}{R}{}{{i}}_{{3}}{}\left({t}\right){,}{{v}}_{{3}}{}\left({t}\right){=}{{\mathrm{vp}}}_{{3}}{}\left({t}\right){-}{{\mathrm{vn}}}_{{3}}{}\left({t}\right)\right\}$ (2)
 > $\mathrm{MapleToModelica}\left(\mathrm{eqs},\mathrm{class_name}="multiphase_common_resistor",\mathrm{parameters}=\left\{R=1\right\},\mathrm{copy_icon}="Modelica.Electrical.MultiPhase.Basic.Resistor",\mathrm{connections}=\left["p"::\mathrm{electrical}\left[\mathrm{num}\right]=\left[\mathrm{seq}\left('\mathrm{vp}\left[k\right],i\left[k\right]',k=1..\mathrm{num}\right)\right]\left(t\right),"n"::\mathrm{electrical}\left[\mathrm{num}\right]=\left[\mathrm{seq}\left('\mathrm{vn}\left[k\right],-i\left[k\right]',k=1..\mathrm{num}\right)\right]\left(t\right)\right],\mathrm{unfilled_pins}=\left\{"n"\right\},\mathrm{omit_annotations},\mathrm{display}\right):$
 model multiphase_common_resistor     Modelica.Electrical.Analog.Interfaces.PositivePin p[3];     Modelica.Electrical.Analog.Interfaces.NegativePin n[3];     parameter Real R = 1;     Real i[3];     Real v[3];     Real vn[3];     Real vp[3]; equation     v[1] = R * i[1];     v[1] = vp[1] - vn[1];     v[2] = R * i[2];     v[2] = vp[2] - vn[2];     v[3] = R * i[3];     v[3] = vp[3] - vn[3];     n[1].i = -i[1];     n[1].v = vn[1];     n[2].i = -i[2];     n[2].v = vn[2];     n[3].i = -i[3];     n[3].v = vn[3];     p[1].i = i[1];     p[1].v = vp[1];     p[2].i = i[2];     p[2].v = vp[2];     p[3].i = i[3];     p[3].v = vp[3]; end multiphase_common_resistor;

Custom Connector

If the option class=connector is passed to MapleToModelica, the output is a Modelica connector definition. This can then be used with the custom_connectors option in a subsequent call to MapleToModelica.

Assign a function that prepends Modelica.SIunits. to a string.

 > $\mathrm{SI}≔\mathrm{dim}↦\mathrm{sprintf}\left("Modelica.SIunits.%s",\mathrm{dim}\right):$

Create the modelica for a custom connector that models both electrical and thermal connections. It has variables for voltage, current, temperature, and heat-flow.

 > $\mathrm{ETmo}≔\mathrm{MapleToModelica}\left(\mathrm{class}=\mathrm{connector},\mathrm{class_name}="ETconn",\mathrm{connections}=\left[v::\mathrm{SI}\left("Voltage"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Voltage at connection",\mathrm{flow}\left(i\right)::\mathrm{SI}\left("Current"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Current into connection",T::\mathrm{SI}\left("Temperature"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Temperature at connection",\mathrm{flow}\left(Q\right)::\mathrm{SI}\left("HeatFlowRate"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Heat flow into connection"\right],\mathrm{display}\right):$
 connector ETconn     Modelica.SIunits.Voltage v "Voltage at connection";     flow Modelica.SIunits.Current i "Current into connection";     Modelica.SIunits.Temperature T "Temperature at connection";     flow Modelica.SIunits.HeatFlowRate Q "Heat flow into connection"; end ETconn;

Assign the equations for a voltage source with a series resistor.

 > $\mathrm{eqs}≔\left\{P\left(t\right)=R{i\left(t\right)}^{2},T\left(t\right)=\mathrm{Tr}\left(t\right)+\mathrm{Rth1}Q\left(t\right),\mathrm{Tr}\left(t\right)=\mathrm{Rth2}\left(P\left(t\right)+Q\left(t\right)\right)+\mathrm{Ta},v\left(t\right)=V+Ri\left(t\right)\right\}$
 ${\mathrm{eqs}}{≔}\left\{{P}{}\left({t}\right){=}{R}{}{{i}{}\left({t}\right)}^{{2}}{,}{T}{}\left({t}\right){=}{\mathrm{Tr}}{}\left({t}\right){+}{\mathrm{Rth1}}{}{Q}{}\left({t}\right){,}{\mathrm{Tr}}{}\left({t}\right){=}{\mathrm{Rth2}}{}\left({P}{}\left({t}\right){+}{Q}{}\left({t}\right)\right){+}{\mathrm{Ta}}{,}{v}{}\left({t}\right){=}{V}{+}{R}{}{i}{}\left({t}\right)\right\}$ (3)

Generate the modelica, using the custom connector.

 > $\mathrm{MapleToModelica}\left(\mathrm{eqs},\mathrm{class_name}="supply",\mathrm{connections}=\left["ET"::\mathrm{ETconn}=\left[v,i,T,Q\right]\left(t\right)\right],\mathrm{custom_connectors}=\left\{\mathrm{ETconn}=\mathrm{ETmo}\right\},\mathrm{parameters}=\left\{R::\mathrm{SI}\left("Resistance"\right)=1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Supply series resistance",\mathrm{Rth1}::\mathrm{SI}\left("ThermalResistance"\right)=1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Thermal resistance from port to resistor",\mathrm{Rth2}::\mathrm{SI}\left("ThermalResistance"\right)=1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Thermal resistance from resistor to ambient",\mathrm{Ta}::\mathrm{SI}\left("Temperature"\right)=300\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Ambient temperature",V::\mathrm{SI}\left("Voltage"\right)=1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Supply open-circuit voltage"\right\},\mathrm{variables}=\left\{P::\mathrm{SI}\left("Power"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Power dissipation in resistor",Q::\mathrm{SI}\left("HeatFlowRate"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Heat flow rate into thermal port",T::\mathrm{SI}\left("Temperature"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Temperature at thermal port",\mathrm{Tr}::\mathrm{SI}\left("Temperature"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Temperature of resistor",i::\mathrm{SI}\left("Current"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Current into electrical pin",v::\mathrm{SI}\left("Voltage"\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}"Voltage at electrical pin"\right\},\mathrm{omit_annotations},\mathrm{display}\right):$
 model supply     extends Maplesoft.Icons.CustomComponent;     ETconn ET;     parameter Modelica.SIunits.Resistance R = 1 "Supply series resistance";     parameter Modelica.SIunits.ThermalResistance Rth1 = 1 "Thermal resistance from port to resistor";     parameter Modelica.SIunits.ThermalResistance Rth2 = 1 "Thermal resistance from resistor to ambient";     parameter Modelica.SIunits.Temperature Ta = 300 "Ambient temperature";     parameter Modelica.SIunits.Voltage V = 1 "Supply open-circuit voltage";     Modelica.SIunits.Power P "Power dissipation in resistor";     Modelica.SIunits.HeatFlowRate Q "Heat flow rate into thermal port";     Modelica.SIunits.Temperature T "Temperature at thermal port";     Modelica.SIunits.Temperature Tr "Temperature of resistor";     Modelica.SIunits.Current i "Current into electrical pin";     Modelica.SIunits.Voltage v "Voltage at electrical pin"; equation     P = R * i ^ 2;     T = Tr + Rth1 * Q;     v = V + R * i;     Tr = Rth2 * (P + Q) + Ta;     ET.Q = Q;     ET.T = T;     ET.i = i;     ET.v = v; end supply; connector ETconn     Modelica.SIunits.Voltage v "Voltage at connection";     flow Modelica.SIunits.Current i "Current into connection";     Modelica.SIunits.Temperature T "Temperature at connection";     flow Modelica.SIunits.HeatFlowRate Q "Heat flow into connection"; end ETconn;