- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Frequency domain analysis of a circuit.
Frequency domain analysis of a circuit.
Frequency domain analysis of a circuit.
Hello,
In Modelica, whenever we give the command for simulation, the variables in the system are computed as functions of time.
But, suppose we want to determine the frequency response of a system and plot the magnitude and phase angle plot, we need to plot these two quantities with respect to frequency. How is this possible in Modelica?
Thanks for your help.
R S Ananda Murthy
Re: Frequency domain analysis of a circuit.
Basically Modelica is devoted to time-domain analysis.
However, if you use circuits built with Quasi-Stationary components, it is easy to create Bode diagrams.
You can have a look at the following model.
It works nicely in Dymola but unfortunately it does not work in OpenModelica.
For instance you can verify that there is a resonance peak at 1600 Hz looking at the Rload voltage (Rload.v.re, Rload.v.im, Urms)
model bode
parameter Real omega=100*Modelica.Constants.pi;
Real Urms=(Rload.v.re^2+Rload.v.im^2)^2;
Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Resistor R(R_ref=1)
annotation (Placement(transformation(extent={{-12,34},{8,54}})));
Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Inductor L(L=1e-3)
annotation (Placement(transformation(extent={{16,34},{36,54}})));
Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Ground ground
annotation (Placement(transformation(extent={{-36,-64},{-16,-44}})));
Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Resistor Rload(R_ref=100)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=-90,
origin={90,12})));
Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Capacitor C(C=1e-5)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=-90,
origin={54,12})));
Modelica.Electrical.QuasiStationary.SinglePhase.Sources.VariableVoltageSource
variableVoltageSource annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
rotation=-90,
origin={-40,4})));
Modelica.Blocks.Sources.Ramp ramp(offset=1, height=10000)
annotation (Placement(transformation(extent={{-90,-38},{-70,-18}})));
Modelica.ComplexBlocks.Sources.ComplexConstant const(k=Complex(1, 0))
annotation (Placement(transformation(extent={{-92,18},{-72,38}})));
equation
connect(R.pin_n, L.pin_p) annotation (Line(
points={{8,44},{16,44}},
color={85,170,255},
smooth=Smooth.None));
connect(L.pin_n, Rload.pin_p) annotation (Line(
points={{36,44},{90,44},{90,22}},
color={85,170,255},
smooth=Smooth.None));
connect(C.pin_p, Rload.pin_p) annotation (Line(
points={{54,22},{54,44},{90,44},{90,22}},
color={85,170,255},
smooth=Smooth.None));
connect(variableVoltageSource.pin_p, R.pin_p) annotation (Line(
points={{-40,14},{-40,44},{-12,44}},
color={85,170,255},
smooth=Smooth.None));
connect(variableVoltageSource.pin_n, Rload.pin_n) annotation (Line(
points={{-40,-6},{-40,-20},{90,-20},{90,2}},
color={85,170,255},
smooth=Smooth.None));
connect(C.pin_n, Rload.pin_n) annotation (Line(
points={{54,2},{54,-20},{90,-20},{90,2}},
color={85,170,255},
smooth=Smooth.None));
connect(ground.pin, Rload.pin_n) annotation (Line(
points={{-26,-44},{-26,-20},{90,-20},{90,2}},
color={85,170,255},
smooth=Smooth.None));
connect(variableVoltageSource.f, ramp.y) annotation (Line(
points={{-50,1.77636e-015},{-60,1.77636e-015},{-60,-28},{-69,-28}},
color={0,0,127},
smooth=Smooth.None));
connect(const.y, variableVoltageSource.V) annotation (Line(
points={{-71,28},{-60,28},{-60,8},{-50,8}},
color={85,170,255},
smooth=Smooth.None));
annotation (uses(Modelica(version="3.2.1")), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics));
end bode;
- ceraolo
- 147 Posts
Re: Frequency domain analysis of a circuit.
Hello,
Thanks for your reply. The example you have given is working in OpenModelica (SVN Version 1.9.2+dev (r24888).
Can you please explain what is the function of the ramp block and the constant k block?
Anand
Re: Frequency domain analysis of a circuit.
The output of the ramp is the frequency of the signal. Choose the right output depending on the frequency range you want to explore.
The variable source is a component of which you change from the outside frequency and amplitude, in real and imaginary parts (the two components of k constant)
I think that to make interesting bode diagrams we can do as in my example: keep amplitude constant with zero phase (only real component) and vary the frequency.
Maybe you can envisage also other usages of the variable source component.
The basic idea is that quasi stationary models use complex numbers to describe the network. therefore, for me, they are not that important for time domain analysis, but can be very useful for frequency domain evaluations.
- ceraolo
- 147 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Frequency domain analysis of a circuit.