Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Modelicac to OpenModelica (OMC)

Modelicac to OpenModelica (OMC)

Previously posted here: https://www.openmodelica.org/forum/defa … -semicolon, in which I made progress but didn't get all the way there.

Hi everyone,
I'm having trouble porting blocs with I/O ports which used to be compiled by modelicac. The current modelica code is as follows:

model InPutPort
  Real vo;
  input Real vi;
equation
    vi=vo;
end InPutPort;

partial model TwoPin
    Pin p, n;
    Real i, v;
equation
    i = p.i;
    n.i = -i;
    v = p.v - n.v;
end TwoPin;

model Switch
  parameter Real Ron=0.01 "Resistance when the Switch is closed";
  parameter Real Roff=1e5  "Resistance when the switch is open";
  extends TwoPin;
  Real inp,Rx;
equation
  Rx*i= v;
  Rx=if inp >0 then Ron
              else Roff;
end Switch;

This yields an error "Too few equations, under-determined system.", apparently because the I/O are not well-defined for OMC.
With sjoelund's help I tried to update to the following code:

model Switch
  parameter Real Ron=0.01 "Resistance when the Switch is closed";
  parameter Real Roff=1e5  "Resistance when the switch is open";
  extends TwoPin;
  InPutPort in(vi=inp);
  input Real inp;
  Real Rx;
equation
  Rx*i= v;
  Rx=if inp >0 then Ron
              else Roff;
end Switch;

But this gave me an error "Error: No viable alternative near token: InPutPort".
Other attempts yielded other errors, this one seemed to be the best-fit.

Any help would be greatly appreciated!
Regards,
Paul

Re: Modelicac to OpenModelica (OMC)

"in" is a keyword and cannot be used for identifiers.

Re: Modelicac to OpenModelica (OMC)

My bad then. With a different name, OMC yields the same original error (#equations < #variables) but with numbers higher than before (80-82 and now 82-84)...
Paul

Re: Modelicac to OpenModelica (OMC)

Still not making headway, sjoelund would you have any idea on the problem please?

Thanks,
Paul

There are 0 guests and 0 other users also viewing this topic
You are here: