Wolfram Computation Meets Knowledge

Component-BasedSimple Circuit

Block-Based CircuitNext Chapter
Component-Based Circuit

Installation and Setup | Introduction | Multidomain | Components | Custom Components | Hello World | External Functions | Hierarchical Models | Systems

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.


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.

ElectricCircuit | BlockCircuit | ElectricCircuit2

Block-Based Circuit

We begin by creating a block-based model. Before we actually start implementing the model, we have to:

In this example, we want to study the current through the signal voltage as a function of the voltage. To calculate this we have three equations:

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

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


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 we started.


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 we can simulate and plot the resulting current through the signal voltage, and as expected it looks just like the result plotted from the block model.


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

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


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

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


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


Develop a block-based model for the second circuit.

Next Chapter

Custom Components »

Installation and Setup | Introduction | Multidomain | Components | Custom Components | Hello World | External Functions | Hierarchical Models | Systems