Because SetComponent modifies the MapleSim file, for this example we copy the original to a temporary location and then use it.
>
|
|
>
|
|
>
|
|
Link to the MapleSim model.
>
|
|
Assign the equations for a simple nonlinear resistor.
>
|
|
| (2) |
Use MapleToModelica to create Modelica code for the model.
>
|
|
>
|
|
model nonlinear_resistor "Nonlinear resistor, v = R1*i^k"
import Modelica.Units.SI.*;
extends Maplesoft.Icons.CustomComponent;
Modelica.Electrical.Analog.Interfaces.PositivePin p annotation (Placement(transformation(
extent = {
{-110, -10},
{-90, 10}},
rotation = 0)));
Modelica.Electrical.Analog.Interfaces.NegativePin n annotation (Placement(transformation(
extent = {
{90, -10},
{110, 10}},
rotation = 0)));
parameter Modelica.Units.SI.Voltage V1 = 1 "voltage at one ampere";
parameter Real k = 2 "current exponent";
Modelica.Units.SI.Current i;
Modelica.Units.SI.ElectricPotential vn;
Modelica.Units.SI.ElectricPotential vp;
Real v;
equation
v = V1 * i ^ k;
v = vp - vn;
n.i = -i;
n.v = vn;
p.i = i;
p.v = vp;
end nonlinear_resistor;
| |
Add the component to the linked MapleSim model.
A DynamicSystems object can also be attached as a component.
>
|
|
Reassign the systemname field of sys; the new name is used as the model name.
>
|
|
>
|
|