**Complex** numbers are defined via record
Modelica_LinearSystems2.Math.Complex. Basically, the record
consists of the real and imaginary part of a complex number and
functions stored in the record that operate on Complex numbers. A
screenshot of the record and its content is given in the next
figure:

Switch to an interactive Modelica environment (e.g., Dymola command window) and type in the following commands:

import Modelica_LinearSystems2.Math.Complex;

This import statement defines a convenient abbreviation, so that
in the following, we have only to type "Complex" and no longer
"Modelica_LinearSystems2.Complex".

Since the Modelica language has been extended to support the
concept of operator overloading, the definition of record Complex
allows to write the following commands:

import Modelica_LinearSystems2.Math.Complex; j = Complex.j(); c1 = 1 + 3*j; c2 = 1 - 5*j; c3 = c1 + c2;

The original generation of complex numbers by using the record-constructor and calling operation functions is still possible and described at Functions and operators

The overloading concept also includes the build in function 'String', i.e. typing

import Modelica_LinearSystems2.Math.Complex; j = Complex.j(); c1 = 1 + 3*j; Modelica.Utilities.Streams.print("c1 = "+String(c1));

results in

c1 = 1 + 3j

Besides the basic operations, the most important specific functions for Complex numbers are also available, e.g., exp(), sin() or conj() to compute

exp(z) = exp(Re(z)*(cos(Im(z)) + j sin(Im(z))) sin(z) = 1/(2j)*(exp(zj) - exp(-zj)) conj(z) = Re(z) - jIm(z)

respectively.

Function arg() returns the phase angle of the Complex number. The phase angle is not unique. Via the optional second argument phi0, the desired range can be defined, such that

-pi < arg(c,phi0) - phi0 < pi.

For example:

Complex.arg( 1+j*0.5, 4*pi ); // = 4*pi+pi/4 = 13.351...

Note that the operators 'abs'(), 'sqrt'(), and 'max'() in this version of Modelica_LinearSystems2 are not supported by the overloading operator concept yet. Therefore, the original way of function calling, e.g.

a = Complex.'abs'(3 + j*4)

has to be applied.

Name | Description |
---|---|

FunctionsAndOperators | Functions and operators |

Generated at 2020-04-07T01:38:57Z by OpenModelicaOpenModelica 1.16.0~dev-263-g761b5de using GenerateDoc.mos