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

Translation error

Translation error

Hello everyone
I am trying to simulate a code:
model lineNew
extends PowerSystems.Icons.Block;
extends PowerSystems.Generic.Ports.PartialTwoTerminal;
parameter Modelica.SIunits.Resistance R = 1 "active component";
parameter Modelica.SIunits.Inductance L = 1/314 "reactive component";
parameter Modelica.SIunits.AngularFrequency omegaRef;

  model lineTest
  PowerSystems.Generic.FixedVoltageSource fixedVoltageSource annotation(
      Placement(visible = true, transformation(origin = {-62, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  lineNew lineNew annotation(
      Placement(visible = true, transformation(origin = {8, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PowerSystems.Generic.FixedCurrent fixedCurrent(I = 60) annotation(
      Placement(visible = true, transformation(origin = {78, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  inner PowerSystems.System system(f_nom = 50) annotation(
      Placement(visible = true, transformation(origin = {-64, 78}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  equation
    connect(fixedVoltageSource.terminal, lineNew.terminal_p) annotation(
      Line(points = {{-52, 10}, {-2, 10}, {-2, 10}, {-2, 10}}, color = {0, 120, 120}));
  connect(lineNew.terminal_n, fixedCurrent.terminal) annotation(
      Line(points = {{18, 10}, {68, 10}, {68, 10}, {68, 10}}, color = {0, 120, 120}));
  end lineTest;
equation
if PhaseSystem.m > 0 then
  omegaRef = der(PhaseSystem.thetaRef(terminal_p.theta));
  else
  omegaRef = 0;
  end if;
  v = R*i + omegaRef*L*j(i);
  zeros(PhaseSystem.n)= terminal_p.i + terminal_n.i;
  if PhaseSystem.m>0 then
  terminal_p.theta = terminal_n.theta;
  end if;
annotation(Icon, Diagram,
    uses(PowerSystems(version = "1.0.0")));
end lineNew;

This is code for lineTest:

model Linetest
  PowerSystems.Generic.FixedVoltageSource fixedVoltageSource annotation(
    Placement(visible = true, transformation(origin = {-62, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PowerSystems.Generic.FixedCurrent fixedCurrent(I = 60) annotation(
    Placement(visible = true, transformation(origin = {78, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  inner PowerSystems.System system(f_nom = 50) annotation(
    Placement(visible = true, transformation(origin = {-64, 78}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  lineNew lineNew annotation(
    Placement(visible = true, transformation(origin = {8, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(lineNew.terminal_n, fixedCurrent.terminal) annotation(
    Line(points = {{18, 10}, {68, 10}}, color = {0, 120, 120}));
  connect(lineNew.terminal_p, fixedVoltageSource.terminal) annotation(
    Line(points = {{-2, 10}, {-52, 10}}, color = {0, 120, 120}));
  annotation(
    uses(PowerSystems(version = "1.0.0")));
end Linetest;

I am getting error message as : Found a component with same name when looking for type lineNew
As I am new to openmodelica, not able to resolve this error. Please help me figuring out what is the mistake I am making.

Re: Translation error

The problem is that you have a model with name "lineNew" and a component with the same name "lineNew". Change model lineNew to "model LineNew ... end LineNew". Modelica doesn't like the name of the types to be the same as the name of the variable so:
As a convention start model/types names with big letter and variables with small letter to avoid this problem

Code:


typeName typeName; // this is wrong
TypeName typeName; //this is fine

Re: Translation error

How to change the name of the model? Actually IineNew is one model which have been used as a component in another model linetest.

There are 0 guests and 0 other users also viewing this topic