Skip to content

Commit

Permalink
modelica#1890 reverted changes (Complex matrix vector multiplication …
Browse files Browse the repository at this point in the history
…added in MSL trunk)

Reverted changes from r9051, so the matrix-vector product function is removed and the matrix-vector product of complex arrays is replaced by the previoius array comprehension implementation.
The reason is that r9051 did not work in OpenModelica.
The reverted change has been tested to work in Dymola and in OpenModelica.

git-svn-id: https://svn.modelica.org/projects/Modelica/trunk@9073 7ce873d0-865f-4ce7-a662-4bb36ea78beb
  • Loading branch information
otter committed Feb 26, 2016
1 parent 1904de3 commit bbff65b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
9 changes: 0 additions & 9 deletions Modelica/ComplexMath.mo
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,6 @@ to the original vector are given, such that sorted_v = v[indices].
</html>"));
end sort;

function matrixVectorProduct "Returns M*v of a Complex matrix M and a Complex vector v"
extends Modelica.Icons.Function;
input Complex M[:,:] "Complex matrix";
input Complex v[size(M,2)] "Complex vector";
output Complex result[size(M,1)] "Complex result vector M*v";
algorithm
result:={Modelica.ComplexMath.'sum'({M[j,k]*v[k] for k in 1:size(M,2)}) for j in 1:size(M,1)};
annotation(Inline=true);
end matrixVectorProduct;
annotation(Documentation(info="<html>
<p>
This library provides functions operating on vectors
Expand Down
12 changes: 4 additions & 8 deletions Modelica/Electrical/QuasiStationary/MultiPhase.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2018,21 +2018,17 @@ This block determines the continuous quasi <a href=\"Modelica://Modelica.Blocks.

block SymmetricalComponents
"Creates symmetrical components from signals representing quasi static phasors"
import Modelica.ComplexMath.Vectors.matrixVectorProduct;
extends Modelica.ComplexBlocks.Interfaces.ComplexMIMO(final nin=m,final nout=m);
parameter Integer m=3 "Number of phases";
protected
final parameter Complex sTM[m, m]=
Modelica.Electrical.MultiPhase.Functions.symmetricTransformationMatrix(m);
equation
// Symmetrical components (preferred): y = sTM*u;
/*
for j in 1:m loop
y[j] = Complex(sum({sTM[j,k].re*u[k].re - sTM[j,k].im*u[k].im for k in 1:m}),
sum({sTM[j,k].re*u[k].im + sTM[j,k].im*u[k].re for k in 1:m}));
end for;
*/
y = matrixVectorProduct(sTM,u);
for j in 1:m loop
y[j] = Complex(sum({sTM[j,k].re*u[k].re - sTM[j,k].im*u[k].im for k in 1:m}),
sum({sTM[j,k].re*u[k].im + sTM[j,k].im*u[k].re for k in 1:m}));
end for;
annotation ( Icon(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics={
Expand Down
18 changes: 6 additions & 12 deletions Modelica/Magnetic/QuasiStatic/FundamentalWave.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3103,7 +3103,6 @@ relationship of the voltage and current space phasor.
model MultiPhaseElectroMagneticConverter
"Multi phase electro magnetic converter"
import Modelica.Constants.pi;
import Modelica.ComplexMath.Vectors.matrixVectorProduct;
constant Complex j=Complex(0, 1);
Modelica.Electrical.QuasiStationary.MultiPhase.Interfaces.PositivePlug
plug_p(final m=m) "Positive plug" annotation (Placement(transformation(
Expand Down Expand Up @@ -3186,17 +3185,12 @@ relationship of the voltage and current space phasor.
"Indices of all positive sequence components";
equation
// Symmetrical components (preferred): vSymmetricalComponent = sTM*v; iSymmetricalComponent = sTM*i;
/*
for j in 1:m loop
vSymmetricalComponent[j] = Complex(sum({sTM[j,k].re*v[k].re - sTM[j,k].im*v[k].im for k in 1:m}),
sum({sTM[j,k].re*v[k].im + sTM[j,k].im*v[k].re for k in 1:m}));
iSymmetricalComponent[j] = Complex(sum({sTM[j,k].re*i[k].re - sTM[j,k].im*i[k].im for k in 1:m}),
sum({sTM[j,k].re*i[k].im + sTM[j,k].im*i[k].re for k in 1:m}));
end for;
*/
vSymmetricalComponent = matrixVectorProduct(sTM,v);
iSymmetricalComponent = matrixVectorProduct(sTM,i);

for j in 1:m loop
vSymmetricalComponent[j] = Complex(sum({sTM[j,k].re*v[k].re - sTM[j,k].im*v[k].im for k in 1:m}),
sum({sTM[j,k].re*v[k].im + sTM[j,k].im*v[k].re for k in 1:m}));
iSymmetricalComponent[j] = Complex(sum({sTM[j,k].re*i[k].re - sTM[j,k].im*i[k].im for k in 1:m}),
sum({sTM[j,k].re*i[k].im + sTM[j,k].im*i[k].re for k in 1:m}));
end for;
// Magnetic flux and flux balance of the magnetic ports
port_p.Phi = Phi;
port_p.Phi + port_n.Phi = Complex(0, 0);
Expand Down

0 comments on commit bbff65b

Please sign in to comment.