Using model hierarchies

We now look at the definition of a generic passive electrical dipole. This component will be connected to an electrical circuit via its input (Pin) and output (Pout) ports.

../_images/Component.png

More generic and reusable components

Let’s assume that a Port has a potential V and an algebraic current I flowing through it. We can then model a Port as follow.

Model Port ()
Constants

Variables
V : Voltage ;
I : Current ;

Elements

Properties

End

A Dipole then consists of two Pin and Pout ports, which are instances of the Port model and that are parts of the component. That is to say that as soon as a component is instantiated, its ports are also instantiated. Moreover, there are algebraic relationships between the input port current (Pin.I), the output port current (Pout.I)and the current in the component (I). Those relationsships has to be posted in the Properties part of the model. Finally, we want to reference each dipole with an integer number called an index. Rather than typing this parameter as an integer, we’ll take the opportunity to define a positive ordinal quantity, with no dimension (u) and no unit (u). This Quantity called DipoleIndex will refer to the predefined QuantityKind Integer.

Quantity DipoleIndex
Kind : Integer ;
Min  : 1 ;
Max : 10 ;
Unit : u ;
End
Model Dipole (index)
Constants
index : DipoleIndex ;

Variables
I : Current ;

Elements
Pin : Port();
Pout : Port() ;

Properties
Pin.I =  I;
Pout.I = -I;

End

In this way, we can derive (keyword extends) a resistance model from the Dipole model. A resistor is a passive component subject to ohm’s law.

Warning

Extending a DEPS model requires us to specify the signature of the model we are extending using the extends keyword. The extended model thus explicitly contains its own constants, variables, elements and properties, and implicitly all the constants, variables, elements and properties of the model it extends. In DEPS an extension is a simple one. Each model can be an extension of at most one model.

Model Resistor(R) extends Dipole[DipoleIndex]
Constants
R : Resistor;

Variables

Elements

Properties
Pin.V-Pout.V = R*I;

End

Modeling the problem

The definition of the problem is now very simple: we create a resistor Res and we set the potential of its Pin (Res.Pin.V = e) and Pout (Res.Pout.V = 0) Ports.

Problem One Resistor
Constants
e : Voltage = 10 ;

Variables

Elements
Res : Resistor(1,100.0) ;

Properties
Res.Pin.V  = e ;
Res.Pout.V  = 0;

End

Compiling and solving the problem

A zipfile containing the whole DEPS project OneResistor.proj described in this section can be downloaded via this link .

From an operational point of view, the DEPS project is organised into two packages:

  • The Component.deps package contains the additional quantities useful to the project (Resistance, DipoleIndex), the Port Model and the Resistor Model.

Package Component ;

Uses Universal;

QuantityKind Resistance
Type : real ;
Min  : 0 ;
Max  : +maxreal ;
Dim  : ML2Tminus3Iminus2 ; (* M.L^2.T^-3.I^-2 *)
End

Quantity Resistance
Kind : Resistance ;
Min  : 0 ;
Max  : +maxreal ;
Unit : ohm ;
End

Quantity DipoleIndex
Kind : Integer ;
Min  : 1 ;
Max : 10 ;
Unit : u ;
End


Model Port ()
Constants

Variables
V: Voltage;
I: Current;

Elements

Properties

End

Model Dipole (index)
Constants
index: DipoleIndex;

Variables
I: Current;

Elements
Pin: Port();
Pout: Port();

Properties
Pin.I =  I;
Pout.I = -I;

End

Model Resistor(R) extends Dipole[DipoleIndex]
Constants
R: Resistance;

Variables

Elements

Properties
Pin.V - Pout.V = R*I;

End
  • The OneResistor.deps package containing the description of the problem.

Package OneResistor ;

Uses Universal, Component  ;

Problem OneResistor
Constants
e: Voltage = 10;

Variables

Elements
Res: Resistor(1, 100.0);

Properties
Res.Pin.V = e;
Res.Pout.V = 0;

End

After opening the OneResistor.proj project file in DEPS Studio, we can compile the project (project > build the problem).

../_images/OneResistorWithoutExprCompile.png

Then the problem can be solved (Solve > Firts Solution).

../_images/OneResistorWithoutExprSolve.png