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

Do not fail for w<=0 in Complex TransferFunction #3677

Merged
merged 6 commits into from
Mar 15, 2021

Conversation

HansOlsson
Copy link
Contributor

Trying to simulate TransferFunction for w=0 fails because (j*w)^(i-1) tries to compute a complex power which fails for zero exponent.
This change corrects that in two different ways - we could decide to do just one of them.

  1. By handling it in TransferFunction - There is an extra protected function, but it could be removed by some loss of readability.
  2. By introducing Complex ^Integer in the complex class; note that by using the type of the exponent we avoid the odd cases in a safe way.

Complex.mo Outdated Show resolved Hide resolved
Complex.mo Outdated Show resolved Hide resolved
Modelica/ComplexBlocks/ComplexMath/TransferFunction.mo Outdated Show resolved Hide resolved
Modelica/ComplexBlocks/ComplexMath/TransferFunction.mo Outdated Show resolved Hide resolved
@beutlich beutlich added the L: Complex* Issue addresses Complex, Modelica.ComplexBlocks or Modelica.ComplexMath label Nov 28, 2020
HansOlsson and others added 3 commits December 2, 2020 09:42
Co-authored-by: Thomas Beutlich <modelica@tbeu.de>
Copy link
Contributor

@christiankral christiankral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we use j not i of the complex notation in Modelica, I wonder if shall call the function PowerOfJ instead of PowerOfI

Copy link
Contributor

@christiankral christiankral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good

@christiankral
Copy link
Contributor

We have keep in mind to later consider #3651 and modify the PR #3733 accordingly

@HansOlsson HansOlsson merged commit 6c72622 into modelica:master Mar 15, 2021
@HansOlsson HansOlsson deleted the AllowNegativeW branch March 15, 2021 08:39
@beutlich beutlich added this to the MSL4.1.0 milestone Mar 15, 2021
@beutlich beutlich assigned HansOlsson and unassigned MartinOtter Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: Complex* Issue addresses Complex, Modelica.ComplexBlocks or Modelica.ComplexMath
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants