Wolfram Computation Meets Knowledge

Components versus Blocks

Block-Based CircuitComponent-Based Circuit

Block-based modeling is well suited for problems that have a well-defined causality, i.e. direction of flow. An example of this type of signal-based system is a control system. However, in most cases the causality is not predefined; for instance, a motor could also be used as a generator, depending on whether or not the input signal is the current or torque. Another basic example is the AC circuit below.

1.gif

The draft schematics of an AC circuit model.

In this example, the circuit above will be used to illustrate the difference between a block-based approach and a component-based approach to modeling.

MODELS USED IN THIS TUTORIAL
ElectricCircuit | BlockCircuit | ElectricCircuit2

Block-Based Circuit

Begin by creating a block-based model. Before you actually start implementing the model, you have to:

In this example, you want to study the current through the sine voltage source in response to different frequencies of the driving voltage. To calculate this, you have three equations:

In these equations, i is the total current through the sine voltage source, and i1 and i2 are the currents running through resistor1 and resistor2, respectively. Rewrite the above equations to not contain derivatives:

With these equations, you can now implement the block-based model, as shown below.

7.gif

The Diagram View of the IntroductoryExamples.ComponentBased.BlockCircuit model.

Create a new model and locate the components in the Class Browser. All components required to implement the system with a block-based approach can be found in the following packages:

Component-Based Circuit

Naturally, implementing a component-based model of the system shown in the original drawing requires only drag-and-drop, as well as connecting the components and setting parameters. This leaves us with a model that looks just like the drawing with which you started.

10.gif

The Diagram View of the IntroductoryExamples.ComponentBased.ElectricCircuit model.

If you would like to build the model yourself, the sine voltage component is located in the Modelica.Electrical.Analog.Sources package, and the rest of the components in the Modelica.Electrical.Analog.Basic package. Note that some of the parameter values differ from the default, so in order to obtain the same simulation results you will have to change these as well.

Now you can simulate and plot the current sineVoltage1.i, and as expected it looks just like the result plotted from the block model.

11.gif

Plotting the current going through the sine voltage source for the IntroductoryExamples.ComponentBased.ElectricCircuit model with default parameter values.

You will end this section by adding a second capacitor to the model, as shown below. The capacitor component is located in the Modelica.Electrical.Analog.Basic package.

12.gif

The Diagram View of the IntroductoryExamples.ComponentBased.ElectricCircuit2 model.

After simulation, you compare the resulting currents with one another.

13.gif

Comparison between the two currents going through the sine voltage source in the ElectricCircuit and ElectricCircuit2 models.

Exercise

Develop a block-based model for the second circuit.