Using models
Representing a problem in a flat form has a number of drawbacks: the model is unreadable, there is no genericity, no extensibility and no reusability.
In DEPS, it is possible to structure the problem using models. A model can represent a sub-system, a component, a function, a point of view, etc. Here we are going to build a model of a resistor whose ohmic value can be parameterised. The resistance model will encapsulate its own constants, variables and properties to be satisfied. A resistor is a passive dipole through which a current (I) flows and which is subject to a voltage (V) at its terminals, in accordance with Ohm’s law.
Structure of a model
Syntacticallly speaking, a Model has the same structure than a Problem but with arguments.
Model Resistor( … )
Constants
Variables
Elements
Properties
End
Modeling a parametrised resistor component
We can now describe the behavioural model of a resistor with a parameterised ohmic value R. Every Resistor, instance of the Resistor Model, has to satisfy the ohm’s law between the voltage (U), the Current (I) and the resistance value (R).
Model Resistor(R)
Constants
R : Resistor;
Variables
U : Voltage;
I : Current;
Elements
Properties
U = R*I;
End
Warning
In DEPS , arguments of a Model can be real or integer values, Constants or Elements. No Variables can be directed passed as an argument of a Model.
Modeling the problem
The representation of the problem is then simplified as follow:
Problem OneResistorV0
Constants
e : Voltage = 10 ;
R : Resistor = 100;
Variables
Elements
res : Resistor(R);
Properties
res.U = e;
End
An instance of the resistor model named res has been created in the Elements zone, reserved for this purpose. The problem thus consists of an element res instance of Resistor wih an ohmic value of R=100 Ohms to which we have applied a voltage e (res.U = e) and for which we want to compute a current (I).
Compiling and solving the problem
A zipfile containing the whole DEPS project OneResistorV0.proj
described in this section can be downloaded via this link .
From an operational point of view, the OneResistorV0.deps
package is organised as follow:
Package OneResistorV0 ;
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
Model Resistor(R)
Constants
R : Resistance;
Variables
U : Voltage;
I : Current;
Elements
Properties
U = R*I;
End
Problem OneResistorV0
Constants
e : Voltage = 10 ;
R : Resistance = 100;
Variables
Elements
res : Resistor(R);
Properties
res.U = e;
End
After opening the OneResistorV0.proj
project file in DEP Studio, we can compile the project (project > build the problem).

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