- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Modelicac to OpenModelica (OMC)
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.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Modelicac to OpenModelica (OMC)