3

This is a very basic question that I cannot seem to find a solution to.

The following line throws an error in Modelica:

parameter  Real    chargeDensity(unit = "C/m")=10^-10;

The error is:

File "<interactive>", line 6, column 90, after '^' and before '-':
Syntax error: At this point, a primary expression is expected, e.g., a value literal, a component reference, or a function call.

The only way I have found to do this is:

parameter  Real    chargeDensity(unit = "C/m")=1/10^10

Is there a power function or operator in Modelica that accepts a negative exponent? Would I have to use an if clause to check the sign of an exponent variable?

Doug Kimzey
  • 2,279
  • 1
  • 14
  • 21
  • 4
    I'm voting to close this question as off-topic because it is unrelated to the programming language Mathematica. – Daniel Lichtblau Oct 07 '18 at 13:49
  • 1
    @DanielLichtblau SystemModeler questions were voted to be on-topic here: https://mathematica.meta.stackexchange.com/questions/1336/are-questions-about-systemmodeler-on-topic , and since Modelica is the underlying language for SystemModeler, this should be on-topic as well. – Malte Lenz Oct 08 '18 at 07:17
  • @MalteLenz Is there any indication that SystemModeler was being used here? – Daniel Lichtblau Oct 08 '18 at 14:49
  • @DanielLichtblau As a SystemModeler developer, I recognize the error message ;). But otherwise, no there isn't. Also as a SystemModeler developer, I don't think its my place to decide whether this is on-topic or not. I'll stand aside now and let the rest of the community make such decisions. – Malte Lenz Oct 08 '18 at 14:55
  • 1
    @MalteLenz SystemModeler questions are of course fair game. This one is well disguised though. – Daniel Lichtblau Oct 08 '18 at 17:21

1 Answers1

3

The solution is:

parameter  Real    chargeDensity(unit = "C/m")=10^(-10.0);

An error is produced for negative exponents if the parenthesis are omitted.

Doug Kimzey
  • 2,279
  • 1
  • 14
  • 21