Modelica.Blocks.Math

Mathematical functions as input/output blocks

Modelica.Blocks.Math.Gain Modelica.Blocks.Math.MatrixGain Modelica.Blocks.Math.Sum Modelica.Blocks.Math.Feedback Modelica.Blocks.Math.Add Modelica.Blocks.Math.Add3 Modelica.Blocks.Math.Product Modelica.Blocks.Math.Division Modelica.Blocks.Math.Abs Modelica.Blocks.Math.Sign Modelica.Blocks.Math.Sqrt Modelica.Blocks.Math.Sin Modelica.Blocks.Math.Cos Modelica.Blocks.Math.Tan Modelica.Blocks.Math.Asin Modelica.Blocks.Math.Acos Modelica.Blocks.Math.Atan Modelica.Blocks.Math.Atan2 Modelica.Blocks.Math.Sinh Modelica.Blocks.Math.Cosh Modelica.Blocks.Math.Tanh Modelica.Blocks.Math.Exp Modelica.Blocks.Math.Log Modelica.Blocks.Math.Log10

Information


This package contains basic mathematical operations, such as summation and multiplication, and basic mathematical functions, such as sqrt and sin, as input/output blocks. All blocks of this library can be either connected with continuous blocks or with sampled-data blocks. In particular the following operations and functions are provided:

   Gain          Output the input multiplied by a scalar gain           
   MatrixGain    Output the product of a gain matrix with the input
   Sum           Output the sum of the elements of the input vector 
   Feedback      Output difference between commanded and feedback input        
   Add           Output the sum of the two inputs 
   Add3          Output the sum of the three inputs 
   Product       Output product of the two inputs 
   Division      Output first input divided by second input
   Abs           Output the absolute value of the input
   Sign          Output the sign of the input
   Sqrt          Output the square root of the input
   Sin           Output the sine of the input
   Cos           Output the cosine of the input
   Tan           Output the tangent of the input        
   Asin          Output the arc sine of the input  
   Acos          Output the arc cosine of the input  
   Atan          Output the arc tangent of the input  
   Atan2         Output atan(u1/u2) of the inputs u1 and u2   
   Sinh          Output the hyperbolic sine of the input  
   Cosh          Output the hyperbolic cosine of the input  
   Tanh          Output the hyperbolic tangent of the input  
   Exp           Output the exponential (base e) of the input 
   Log           Output the natural (base e) logarithm of the input 
   Log10         Output the base 10 logarithm of the input    
Main Author:
Martin Otter
Deutsches Zentrum fuer Luft und Raumfahrt e.V. (DLR)
Oberpfaffenhofen
Postfach 1116
D-82230 Wessling
email: Martin.Otter@dlr.de

Release Notes:


Copyright (C) 1999-2000, Modelica Association and DLR.

The Modelica package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".


Modelica.Blocks.Math.Gain Modelica.Blocks.Math.Gain

Output the element-wise product of a gain vector with the input signal vector

Modelica.Blocks.Math.Gain

Information


This blocks computes output y=outPort.signal as element-wise product of gain k with the input u = inPort.signal:

    y[i] = k[i] * u[i];

Release Notes:


Parameters

NameDefaultDescription
k[:]{1}Gain vector multiplied element-wise with input vector

Modelica definition

block Gain 
  "Output the element-wise product of a gain vector with the input signal vector"
   
  
  parameter Real k[:]={1} 
    "Gain vector multiplied element-wise with input vector";
protected 
  Real u[size(k, 1)] "Input signals";
  Real y[size(k, 1)] "Output signals";
public 
  Interfaces.InPort inPort(final n=size(k, 1)) 
    "Input signal connector";
  Interfaces.OutPort outPort(final n=size(k, 1)) 
    "Output signal connector";
equation 
  u = inPort.signal;
  y = outPort.signal;
  for i in 1:size(k, 1) loop
    y[i] = k[i]*u[i];
  end for;
end Gain;

Modelica.Blocks.Math.Add3 Modelica.Blocks.Math.Add3

Output the sum of the three inputs

Modelica.Blocks.Math.Add3

Information


This blocks computes output y=outPort.signal as sum of the three input signals u1=inPort1.signal, u2=inPort2.signal and u3=inPort3.signal:

    y = k1*u1 + k2*u2 + k3*u3;

Example:

     parameter:   n = 2, k1= +2, k2= -3, k3=1;

  results in the following equations:
     
     y[1] = 2 * u1[1] - 3 * u2[1] + u3[1]; 
     y[2] = 2 * u1[2] - 3 * u2[2] + u3[2];

Release Notes:


Parameters

NameDefaultDescription
k1+1Gain of upper input
k2+1Gain of middle input
k3+1Gain of lower input
n1Dimension of input and output vectors.

Modelica definition

block Add3 "Output the sum of the three inputs" 
  extends Interfaces.BlockIcon;
  
  parameter Real k1=+1 "Gain of upper input";
  parameter Real k2=+1 "Gain of middle input";
  parameter Real k3=+1 "Gain of lower input";
  parameter Integer n=1 "Dimension of input and output vectors.";
  Interfaces.InPort inPort1(final n=n) 
    "Connector 1 of Real input signals";
  Interfaces.InPort inPort2(final n=n) 
    "Connector 2 of Real input signals";
  Interfaces.InPort inPort3(final n=n) 
    "Connector 3 of Real input signals";
  Interfaces.OutPort outPort(final n=n) 
    "Connector of Real output signals";
equation 
  outPort.signal = k1*inPort1.signal + k2*inPort2.signal + k3*inPort3.signal;
end Add3;

Modelica.Blocks.Math.Add Modelica.Blocks.Math.Add

Output the sum of the two inputs

Modelica.Blocks.Math.Add

Information


This blocks computes output y=outPort.signal as sum of the two input signals u1=inPort1.signal and u2=inPort2.signal:

    y = k1*u1 + k2*u2;

Example:

     parameter:   n = 2, k1= +2, k2= -3

  results in the following equations:
     
     y[1] = 2 * u1[1] - 3 * u2[1] 
     y[2] = 2 * u1[2] - 3 * u2[2]

Release Notes:


Parameters

NameDefaultDescription
n1Dimension of input and output vectors.
k1+1Gain of upper input
k2+1Gain of lower input

Modelica definition

block Add "Output the sum of the two inputs" 
  extends Interfaces.MI2MO;
  parameter Real k1=+1 "Gain of upper input";
  parameter Real k2=+1 "Gain of lower input";
equation 
  y = k1*u1 + k2*u2;
end Add;

Modelica.Blocks.Math.MatrixGain Modelica.Blocks.Math.MatrixGain

Output the product of a gain matrix with the input signal vector

Modelica.Blocks.Math.MatrixGain

Information


This blocks computes output y=outPort.signal as product of the gain matrix K with the input signal vector u = inPort.signal:

    y = K * u;

Example:

   parameter: K = [0.12 2; 3 1.5]

   results in the following equations:

     | y[1] |     | 0.12  2.00 |   | u[1] | 
     |      |  =  |            | * |      | 
     | y[2] |     | 3.00  1.50 |   | u[2] |

Release Notes:


Parameters

NameDefaultDescription
K[:, :][1, 0; 0, 1]Gain matrix which is multiplied with the input

Modelica definition

block MatrixGain 
  "Output the product of a gain matrix with the input signal vector" 
  parameter Real K[:, :]=[1, 0; 0, 1] 
    "Gain matrix which is multiplied with the input";
  extends Interfaces.MIMO(final nin=size(K, 2), final nout=size(K, 1));
equation 
  y = K*u;
end MatrixGain;

Modelica.Blocks.Math.Sum Modelica.Blocks.Math.Sum

Output the sum of the elements of the input vector

Modelica.Blocks.Math.Sum

Information


This blocks computes output y=outPort.signal[1] as sum of the elements of the input signal vector u=inPort.signal:

    y = u[1] + u[2] + ...;

Example:

     parameter:   nin = 3;

  results in the following equations:
     
     y = u[1] + u[2] + u[3];

Release Notes:


Parameters

NameDefaultDescription
nin1Number of inputs

Modelica definition

block Sum "Output the sum of the elements of the input vector" 
  extends Interfaces.MISO;
algorithm 
  y := u[1];
  for i in 2:nin loop
    y := y + u[i];
  end for;
end Sum;

Modelica.Blocks.Math.Feedback Modelica.Blocks.Math.Feedback

Output difference between commanded and feedback input

Modelica.Blocks.Math.Feedback

Information


This blocks computes output y=outPort.signal as difference of the commanded input u1=inPort1.signal and the feedback input u2=inPort2.signal:

    y = u1 - u2;

Example:

     parameter:   n = 2

  results in the following equations:
     
     y[1] = u1[1] - u2[1] 
     y[2] = u1[2] - u2[2]

Release Notes:


Parameters

NameDefaultDescription
n1size of input and feedback signal

Modelica definition

block Feedback 
  "Output difference between commanded and feedback input" 
  parameter Integer n=1 "size of input and feedback signal";
  Interfaces.InPort inPort1(final n=n);
  Interfaces.InPort inPort2(final n=n);
  Interfaces.OutPort outPort(final n=n);
equation 
  outPort.signal = inPort1.signal - inPort2.signal;
end Feedback;

Modelica.Blocks.Math.Product Modelica.Blocks.Math.Product

Output product of the two inputs

Modelica.Blocks.Math.Product

Information


This blocks computes the output y=outPort.signal element-wise as product of the corresponding elements of the two inputs u1=inPort1.signal and u2=inPort2.signal:

    y[i] = u1[i] * u2[i];

Release Notes:


Parameters

NameDefaultDescription
n1Dimension of input and output vectors.

Modelica definition

block Product "Output product of the two inputs" 
  extends Interfaces.MI2MO;
equation 
  for i in 1:n loop
    y[i] = u1[i]*u2[i];
  end for;
end Product;

Modelica.Blocks.Math.Division Modelica.Blocks.Math.Division

Output first input divided by second input

Modelica.Blocks.Math.Division

Information


This block computes the output y=outPort.signal element-wise by dividing the corresponding elements of the two inputs u1=inPort1.signal and u2=inPort2.signal:

    y[i] = u1[i] / u2[i];

Release Notes:


Parameters

NameDefaultDescription
n1Dimension of input and output vectors.

Modelica definition

block Division "Output first input divided by second input" 
  extends Interfaces.MI2MO;
equation 
  for i in 1:n loop
    y[i] = u1[i]/u2[i];
  end for;
end Division;

Modelica.Blocks.Math.Abs Modelica.Blocks.Math.Abs

Output the absolute value of the input

Modelica.Blocks.Math.Abs

Information


This blocks computes the output y=outPort.signal element-wise as absolute value of the input u=inPort.signal:

    y[i] = abs( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Abs "Output the absolute value of the input" 
  extends Interfaces.MIMOs;
equation 
  y = abs(u);
end Abs;

Modelica.Blocks.Math.Sign Modelica.Blocks.Math.Sign

Output the sign of the input

Modelica.Blocks.Math.Sign

Information


This blocks computes the output y=outPort.signal element-wise as sign of the input u=inPort.signal:

            1  if u[i] > 0
    y[i] =  0  if u[i] == 0
           -1  if u[i] < 0 

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Sign "Output the sign of the input" 
  extends Interfaces.MIMOs;
equation 
  y = sign(u);
end Sign;

Modelica.Blocks.Math.Sqrt Modelica.Blocks.Math.Sqrt

Output the square root of the input (input >= 0 required)

Modelica.Blocks.Math.Sqrt

Information


This blocks computes the output y=outPort.signal element-wise as square root of the input u=inPort.signal:

    y[i] = sqrt( u[i] );

All elements of the input vector shall be zero or positive. Otherwise an error occurs.

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Sqrt 
  "Output the square root of the input (input >= 0 required)" 
  extends Interfaces.MIMOs;
equation 
  y = sqrt(u);
end Sqrt;

Modelica.Blocks.Math.Sin Modelica.Blocks.Math.Sin

Output the sine of the input

Modelica.Blocks.Math.Sin

Information


This blocks computes the output y=outPort.signal element-wise as sine of the input u=inPort.signal:

    y[i] = sin( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Sin "Output the sine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.sin(u);
end Sin;

Modelica.Blocks.Math.Cos Modelica.Blocks.Math.Cos

Output the cosine of the input

Modelica.Blocks.Math.Cos

Information


This blocks computes the output y=outPort.signal element-wise as cos of the input u=inPort.signal:

    y[i] = cos( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Cos "Output the cosine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.cos(u);
end Cos;

Modelica.Blocks.Math.Tan Modelica.Blocks.Math.Tan

Output the tangent of the input

Modelica.Blocks.Math.Tan

Information


This blocks computes the output y=outPort.signal element-wise as tan of the input u=inPort.signal:

    y[i] = tan( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Tan "Output the tangent of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.tan(u);
end Tan;

Modelica.Blocks.Math.Asin Modelica.Blocks.Math.Asin

Output the arc sine of the input

Modelica.Blocks.Math.Asin

Information


This blocks computes the output y=outPort.signal element-wise as the sine-inverse of the input u=inPort.signal:

    y[i] = asin( u[i] );

The absolute values of the elements of the input u need to be less or equal to one (abs( u[i] ) <= 1). Otherwise an error occurs.

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Asin "Output the arc sine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.asin(u);
end Asin;

Modelica.Blocks.Math.Acos Modelica.Blocks.Math.Acos

Output the arc cosine of the input

Modelica.Blocks.Math.Acos

Information



This blocks computes the output y=outPort.signal element-wise as the cosine-inverse of the input u=inPort.signal:

    y[i] = acos( u[i] );

The absolute values of the elements of the input u need to be less or equal to one (abs( u[i] ) <= 1). Otherwise an error occurs.

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Acos "Output the arc cosine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.acos(u);
end Acos;

Modelica.Blocks.Math.Atan Modelica.Blocks.Math.Atan

Output the arc tangent of the input

Modelica.Blocks.Math.Atan

Information


This blocks computes the output y=outPort.signal element-wise as the tangent-inverse of the input u=inPort.signal:

    y[i] = atan( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Atan "Output the arc tangent of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.atan(u);
end Atan;

Modelica.Blocks.Math.Atan2 Modelica.Blocks.Math.Atan2

Output atan(u1/u2) of the inputs u1 and u2

Modelica.Blocks.Math.Atan2

Information


This blocks computes the output y=outPort.signal element-wise as the tangent-inverse of the input u1=inPort1.signal divided by input u2=inPort2.signal:

    y[i] = atan2( u1[i], u2[i] );

u1[i] and u2[i] shall not be zero at the same time instant. Atan2 uses the sign of u1[i] and u2[i] in order to construct the solution in the range -180 deg <= y[i] <= 180 deg, whereas block Atan gives a solution in the range -90 deg <= y[i] <= 90 deg.

Release Notes:


Parameters

NameDefaultDescription
n1Dimension of input and output vectors.

Modelica definition

block Atan2 "Output atan(u1/u2) of the inputs u1 and u2" 
  extends Interfaces.MI2MO;
equation 
  y = Modelica.Math.atan2(u1, u2);
end Atan2;

Modelica.Blocks.Math.Sinh Modelica.Blocks.Math.Sinh

Output the hyperbolic sine of the input

Modelica.Blocks.Math.Sinh

Information


This blocks computes the output y=outPort.signal element-wise as the hyperbolic sine of the input u=inPort.signal:

    y[i] = sinh( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Sinh "Output the hyperbolic sine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.sinh(u);
end Sinh;

Modelica.Blocks.Math.Cosh Modelica.Blocks.Math.Cosh

Output the hyperbolic cosine of the input

Modelica.Blocks.Math.Cosh

Information


This blocks computes the output y=outPort.signal element-wise as the hyperbolic cosine of the input u=inPort.signal:

    y[i] = cosh( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Cosh "Output the hyperbolic cosine of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.cosh(u);
end Cosh;

Modelica.Blocks.Math.Tanh Modelica.Blocks.Math.Tanh

Output the hyperbolic tangent of the input

Modelica.Blocks.Math.Tanh

Information


This blocks computes the output y=outPort.signal element-wise as the hyperbolic tangent of the input u=inPort.signal:

    y[i] = tanh( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Tanh "Output the hyperbolic tangent of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.tanh(u);
end Tanh;

Modelica.Blocks.Math.Exp Modelica.Blocks.Math.Exp

Output the exponential (base e) of the input

Modelica.Blocks.Math.Exp

Information


This blocks computes the output y=outPort.signal element-wise as the exponential (of base e) of the input u=inPort.signal:

    y[i] = exp( u[i] );

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Exp "Output the exponential (base e) of the input" 
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.exp(u);
end Exp;

Modelica.Blocks.Math.Log Modelica.Blocks.Math.Log

Output the natural (base e) logarithm of the input (input > 0 required)

Modelica.Blocks.Math.Log

Information


This blocks computes the output y=outPort.signal element-wise as the natural (base e) logarithm of the input u=inPort.signal:

    y[i] = log( u[i] );

An error occurs if the elements of the input u are zero or negative.

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Log 
  "Output the natural (base e) logarithm of the input (input > 0 required)"
   
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.log(u);
end Log;

Modelica.Blocks.Math.Log10 Modelica.Blocks.Math.Log10

Output the base 10 logarithm of the input (input > 0 required)

Modelica.Blocks.Math.Log10

Information


This blocks computes the output y=outPort.signal element-wise as the base 10 logarithm of the input u=inPort.signal:

    y[i] = log10( u[i] );

An error occurs if the elements of the input u are zero or negative.

Release Notes:


Parameters

NameDefaultDescription
n1Number of inputs (= number of outputs)

Modelica definition

block Log10 
  "Output the base 10 logarithm of the input (input > 0 required)"
   
  
  extends Interfaces.MIMOs;
equation 
  y = Modelica.Math.log10(u);
end Log10;

HTML-documentation generated by Dymola Tue Jun 20 21:43:25 2000 .