.ModelicaDEVS.Examples.Electrical.AdditionalBlocks.CapacitorDEVS

Information

The CapacitorDEVS Block

Parameters:
period length of the sampling intervals
start start time of the sampling period


Description:

The figure below illustrates the implementation of the ModelicaDEVS capacitor. In order to be connectable to blocks from the electrical library of Modelica, it has to extend the EEBlock of the ModelicaDEVS library. This block looks like the TwoPin block interface provided by Dymola on its outside, but internally performs a type conversion of the input and output signals: the two blocks inDEVS and outDEVS are used to transform the signals from the electrical pins to signals of type real and vice-versa. The second type conversion is done by means of the SamplerTime and the Interpolator blocks that act as interfaces to non-DEVS components with real-valued input/output signals.
Note that it would have been more appropriate to use the SamplerLevel block, because the scope of DEVS integration is to by-pass the time discretisation. However, as we will see later, it was necessary to program a numerical version of the sampler block, in order to enable mixed simulations. Unfortunately, the numerical version of the SamplerLevel block led to aborted simulations due to "inconsistent restarting conditions". With a numerical version of the SamplerTime block on the other hand, the simulation could be performed without encountering any difficulties. Hence for the sake of consistency, it was decided to only use time sampler blocks instead of a SamplerLevel for the CapacitorDEVS block and a SamplerTimeNumerical for the CapacitorDEVSNumerical block.




The full textual description of the ModelicaDEVS capacitor is given below:
1  model CapacitorDEVS
2    extends ModelicaDEVS.Templates.EEBlock;
3    parameter Modelica.SIunits.Capacitance C=1 "Capacitance";
4    parameter Real period=1e-6 "Sampling period";
5
6    SourceBlocks.SamplerTime SamplerTime1(period=period);
7    FunctionBlocks.Integrator Integrator1;
8    SinkBlocks.Interpolator Interpolator1;
9    FunctionBlocks.Gain Gain1(g=1/C);
10
11 equation
12   connect(SamplerTime1.outPort, Gain1.inPort);
13   connect(Gain1.outPort, Integrator1.inPort);
14   connect(Integrator1.outPortInterpolator, Interpolator1.inPortInterpolator);
15   connect(inDEVS, SamplerTime1.inPort);
16   connect(Interpolator1.outPort, outDEVS);
17 end CapacitorDEVS;
The SamplerTime block (line 6) samples the signal of the electrical current at a period specified by the parameter sampling (line 4), and the Gain block (line 9) multiplies the incoming signal by the value of 1/C, where C is again specified by a parameter (line 3). Taken as a whole, the ModelicaDEVS blocks constitute nothing else than the well known capacitor formula
i=C*dv/dt
in an algebraically modified version:
v=1/C*integral(i)

Unfortunately, the CapacitorDEVS block exhibits two problems - one solvable, the other not yet: