Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polar representation of complex numbers #1405

Closed
modelica-trac-importer opened this issue Jan 14, 2017 · 9 comments
Closed

polar representation of complex numbers #1405

modelica-trac-importer opened this issue Jan 14, 2017 · 9 comments
Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature L: Complex* Issue addresses Complex, Modelica.ComplexBlocks or Modelica.ComplexMath
Milestone

Comments

@modelica-trac-importer
Copy link

Reported by ahaumer on 22 Jan 2014 16:50 UTC
In many cases not only the real and the imaginary part of a complex voltage, current, impedance, power, flux, mmf is of interest, but the user wants to see without any additional effort the length and the angle of the complex phasor in the result. The usage of a pocket calculator to achieve this information is really clumsy.
With the current implementation of complex numbers as operator record there seems to be only one way to achieve this goal (the burden is carried by the library developers of e.g. Electrical.QuasiStationary):

  • define a record (or operator record?) Polar (with length and angle)
  • define all derived types (PolarVoltage, PolarCurrent, ...)
  • implement a function complex2polar
  • in every corresponding model or partial model (e.g. Electrical.QuasiStationary.SinglePhase.Interfaces.TwoPin) define in parallel to ComplexVoltage and ComplexCurrent PolarVoltage and PolarCurrent, and use function complex2polar to calculate them.
record Polar
  replaceable Real len "Length of complex number";
  Modelica.SIunits.Angle phi "Angle of complex number";
end Polar;

function complex2polar
  input Complex c;
  output Polar p;
algorithm 
  p.len := Modelica.ComplexMath.'abs'(c);
  p.phi := Modelica.ComplexMath.arg(c);
end complex2polar;

record PolarCurrent=Polar(redeclare Modelica.SIunits.Current len) 
  "Polar electrical current";

record PolarVoltage=Polar(redeclare Modelica.SIunits.Voltage len) 
  "Polar electrical voltage";

partial model TwoPin "Two pins"
  Modelica.SIunits.ComplexVoltage  v;
  Modelica.SIunits.ComplexCurrent  i;
  PolarVoltage vPolar = complex2polar(v);
  PolarCurrent iPolar = complex2polar(i);
  Modelica.SIunits.AngularVelocity omega;
  ...
end TwoPin;

This solution seems to be a lot of work, and not very elegant. An implicit dual representation of Complex and Polar (with automatic conversion) would be a perfect solution.

Are there any suggestions and comments how to improve the current situation?


Migrated-From: https://trac.modelica.org/Modelica/ticket/1405

@modelica-trac-importer modelica-trac-importer added this to the MSL3.2.2 milestone Jan 14, 2017
@modelica-trac-importer modelica-trac-importer added discussion Discussion issue that it not necessarily related to a concrete bug or feature L: Complex* Issue addresses Complex, Modelica.ComplexBlocks or Modelica.ComplexMath labels Jan 14, 2017
@modelica-trac-importer
Copy link
Author

Modified by christiankral on 26 Jan 2014 08:50 UTC

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 13 Sep 2014 13:33 UTC
For the interface components

  • Modelica.Electrical.QuasiStationary.SinglePhase.Interfaces.TwoPin
  • Modelica.Electrical.QuasiStationary.MultiPhase.Interfaces.OnePort
  • Modelica.Electrical.QuasiStationary.MultiPhase.Interfaces.TwoPlug

the following additional (output) variables have been defined:

  • S = magnitude of complex apparent power

  • P = real power

  • Q = reactive power

  • pf = power factor

  • abs_v = magnitude of complex voltage

  • arg_v = argument of complex voltage

  • abs_i = magnitude of complex current

  • arg_i = argument of complex current

For the interfaces

  • Modelica.Electrical.QuasiStationary.SinglePhase.Interfaces.TwoPin
  • Modelica.Electrical.QuasiStationary.MultiPhase.Interfaces.OnePort

additional variables have been included:

  • S_total = magnitude of total apparent power
  • P_total = total real power
  • Q_total = total reactive power

Implementation performed for 8021728.

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 13 Sep 2014 13:41 UTC
For the package Modelica.Magnetic.QuasiStatic.FundamentalWave the following additional variables are included in interface, electromagnetic coupling and machine models:

  • abs_Phi
  • arg_Phi
  • abs_V_m
  • arg_V_m

In the electromagnetic coupling and machine models also power, magnitude and angle variables were added for voltages and currents. For that purpose the interface model Modelica.Magnetic.QuasiStatic.FundamentalWave.Interfaces.PartialTwoPortExtended was added.

Implementation performed in 48bc47a.

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 13 Sep 2014 16:10 UTC
More improvements in f190766, 8f9bf43, 9578264

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 13 Sep 2014 16:17 UTC
Added magnitude and argument variables for the complex magnetic potential difference and flux in Modelica.Magnetic.FundamentalWave

Implementation performed in ee0711a and 164e12f.

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 13 Sep 2014 16:21 UTC
The actual implementation with real variables of the magnitude and argument, respectively, substitutes the original proposal of polar complex variables. Therefore, this ticket is now closed.

@modelica-trac-importer
Copy link
Author

Comment by christiankral on 2 Feb 2015 11:08 UTC
Added polar representation of single and multi phase sensor outputs, see c3c42de.

@modelica-trac-importer
Copy link
Author

Modified by beutlich on 29 Oct 2015 15:06 UTC

@modelica-trac-importer
Copy link
Author

Changelog modified by beutlich on 29 Oct 2015 15:06 UTC
Added polar representation of single and multi phase sensor outputs in Modelica.Electrical.QuasiStationary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature L: Complex* Issue addresses Complex, Modelica.ComplexBlocks or Modelica.ComplexMath
Projects
None yet
Development

No branches or pull requests