3
$\begingroup$

Consider a linear system .

bandPassOL[omega_, k_] := Module[{a, b, c, d},
  a = {{0, -omega}, {omega, 0}};
  b = {{omega*k}, {0}}; 
  c = {{1, 0}, {0, 1}};
  d = {{0}, {0}};
  StateSpaceModel[{a, b, c, d}]
](*Module*)
osg2SSOL = SystemsModelParallelConnect[bandPassOL[omega1, k1],
   bandPassOL[omega2, k2], All, None];
osg2SSCL = SystemsModelFeedbackConnect[osg2SSOL, {{1, 1}, {3, 1}}];

If I want to plot frequency characteristic of such a SIMO system using BodePlot

BodePlot[osg2SSCL /. {k1 -> 0.5, 
   k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, {10^2, 10^4}, GridLines -> Automatic, 
   PlotLayout -> "Magnitude"]

I get the following, incorrect result.

enter image description here

If, on the other hand, I wrap the system with TransferFunctionModel and send it to BodePlot

BodePlot[TransferFunctionModel[osg2SSCL, s] /. {k1 -> 0.5, 
   k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, {10^2, 10^4}, GridLines -> Automatic, 
   PlotLayout -> "Magnitude"]

I get the correct result.

If I vary coefficients k1 and k2 from 0.01 to 1, the difference between outputs varies. For small values of k1 and k2, the difference is large and easy to spot, but as k1 and k2 approach 1 the difference gets smaller and easy to miss.

I've tried several other systems and seems that the errors starts to appear only if the system has more than 3 outputs. Though this was far from extensive verification.

Should this be considered a bug?

enter image description here

The problem persist through the following versions of MMA

"11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)"

"10.2.0 for Microsoft Windows (64-bit) (July 28, 2015)"

"11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)"

$\endgroup$
2
$\begingroup$

The issue is not in BodePlot, but in the conversion from StateSpaceModel to TransferFunctionModel. Compare:

TransferFunctionModel[osg2SSCL, s] /. {k1 -> 0.5, k2 -> 0.5, 
omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}

enter image description here

and

TransferFunctionModel[osg2SSCL /. {k1 -> 0.5, k2 -> 0.5, omega1 -> 2 Pi 
50, omega2 -> 2 Pi 500}, s]

enter image description here

Adjust the precision for the latter:

BodePlot[TransferFunctionModel[SetPrecision[osg2SSCL /. {k1 -> 0.5, 
k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, 20], s], {10^2, 10^4}, 
GridLines -> Automatic, PlotLayout -> "Magnitude"]

enter image description here

$\endgroup$
  • $\begingroup$ This implies that BodePlot internally calls TransferFunctionModel if the model is in StateSpace representation? $\endgroup$ – ercegovac Oct 4 '18 at 16:26
  • $\begingroup$ That is correct. $\endgroup$ – Suba Thomas Oct 4 '18 at 16:37
  • $\begingroup$ It appears that SetPrecision only helps inside BodePlot function. If you try to evaluate the following TransferFunctionModel[SetPrecision[osg2SSCL /. {k1 -> 0.5, k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, 20], s] on its own, wrong result is again obtained. On the other side if you change Method to "Inverse" as in TransferFunctionModel[osg2SSCL /. {k1 -> 0.5, k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, s, Method->"Inverse"] the correct result is obtained. $\endgroup$ – ercegovac Oct 4 '18 at 16:49
  • $\begingroup$ Increasing the precision makes the result closer, and we cannot tell the difference by looking at the BodePlot. If you want to go one step further down the rabbit hole, the hiccup is in CharactersticPolynomial. The method "Inverse" does not use CharactersticPolynomial, although such a brute approach will choke for larger systems. $\endgroup$ – Suba Thomas Oct 4 '18 at 17:22
  • $\begingroup$ When I evaluate BodePlot[TransferFunctionModel[SetPrecision[osg2SSCL /. {k1 -> 0.5, k2 -> 0.5, omega1 -> 2 Pi 50, omega2 -> 2 Pi 500}, 20], s], {10^2, 10^4}, GridLines -> Automatic, PlotLayout -> "Magnitude"] I still get wrong result. MMA 11.3 @ Win10 $\endgroup$ – ercegovac Oct 4 '18 at 17:54
1
$\begingroup$

Replace k1 and k2 with 1/2

BodePlot[osg2SSCL /. {k1 -> 1/2, k2 -> 1/2, omega1 -> 2 Pi 50, 
   omega2 -> 2 Pi 500}, {10^2, 10^4}, GridLines -> Automatic, 
 PlotLayout -> "Magnitude"]

enter image description here

$\endgroup$
  • $\begingroup$ O just use TransferFunctionModel. The point is, it is most likely a bug and I just wanted to put it out there to get a conformation before submitting bug report to Wolfram Research. $\endgroup$ – ercegovac Oct 4 '18 at 10:21
  • $\begingroup$ @ercegovac I'm not able to read thougths :) $\endgroup$ – rmw Oct 4 '18 at 12:36
  • $\begingroup$ You don't have to, capacity to read written text is sufficient. It says at the end of the question "Should this be considered a bug?" $\endgroup$ – ercegovac Oct 4 '18 at 12:41
  • $\begingroup$ Since we are here, did you encounter the same behavior without resorting to rational numbers? $\endgroup$ – ercegovac Oct 4 '18 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.