Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
0

Modelica buildings outputs error when connecting the terminal

asked 2023-03-28 00:38:46 -0500

grid_designer's avatar

updated 2023-03-28 14:39:54 -0500

Hello, I am trying to connect the grid to a line in the modelica building.electrical library. I get this error:

[2] 18:20:02 Translation Error [Buildings.Electrical.AC.ThreePhasesBalanced.Lines.Line: 4:5-4:47]: Type mismatch in binding terminal_n = grid_connection, expected subtype of Buildings.Electrical.AC.ThreePhasesBalanced.Interfaces.Terminal_n, got type Buildings.Electrical.AC.ThreePhasesBalanced.Sources.Grid

I found this unusual since I am connecting it like the example which does not have an error

My code: https://drive.google.com/drive/folder...

model building
  Buildings.Electrical.AC.ThreePhasesBalanced.Sources.Grid grid_connection annotation(
    Placement(visible = true, transformation(origin = {-82, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Buildings.Electrical.AC.ThreePhasesBalanced.Sources.PVSimpleOriented solar_array(A = 10)  annotation(
    Placement(visible = true, transformation(origin = {-106, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Buildings.Electrical.AC.ThreePhasesBalanced.Loads.Resistive building_load annotation(
    Placement(visible = true, transformation(origin = {-4, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Buildings.Electrical.AC.ThreePhasesBalanced.Storage.Battery BESS(EMax = 1800000000, SOC_start = 20)  annotation(
    Placement(visible = true, transformation(origin = {-82, -46}, extent = {{-10, -10}, {10, 10}}, rotation = 270)));
  Buildings.Electrical.AC.ThreePhasesBalanced.Lines.Line grid_line(terminal_n = grid_connection)  annotation(
    Placement(visible = true, transformation(origin = {-40, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

  Buildings.BoundaryConditions.WeatherData.ReaderTMY3 weather_data(filNam = "weather.mos")  annotation(
    Placement(visible = true, transformation(origin = {-184, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.CombiTimeTable load_data(columns = 15:44640, fileName = "data.txt", tableOnFile = true, timeScale = 60, verboseRead = true)  annotation(
    Placement(visible = true, transformation(origin = {29, 13}, extent = {{9, -9}, {-9, 9}}, rotation = 0)));
  Modelica.Blocks.Sources.CombiTimeTable bess_data annotation(
    Placement(visible = true, transformation(origin = {-48, -46}, extent = {{8, -8}, {-8, 8}}, rotation = 0)));
equation
  connect(BESS.terminal, grid_line.terminal_n) annotation(
    Line(points = {{-82, -36}, {-48, -36}, {-48, 12}, {-50, 12}}, color = {255, 255, 255}));
  connect(grid_line.terminal_n, BESS.terminal) annotation(
    Line(points = {{-50, 12}, {-82, 12}, {-82, -36}}));
  connect(grid_line.terminal_n, solar_array.terminal) annotation(
    Line(points = {{-50, 12}, {-96, 12}}));
  connect(grid_line.terminal_p, building_load.terminal) annotation(
    Line(points = {{-30, 12}, {-14, 12}}));
  connect(load_data.y, building_load.Pow) annotation(
    Line(points = {{19, 13}, {13.5, 13}, {13.5, 12}, {6, 12}}, color = {0, 0, 127}));
  connect(bess_data.y, BESS.P) annotation(
    Line(points = {{-56, -46}, {-72, -46}}, color = {0, 0, 127}));
  connect(weather_data.weaBus, solar_array.weaBus) annotation();
  annotation(
    uses(Buildings(version = "9.1.0"), Modelica(version = "4.0.0")));
end building;

Example Code:

within Buildings.Electrical.Examples;
model RenewableSources
  AC.ThreePhasesBalanced.Sources.Grid gri(
    f=f,
    V=V_nominal,
    phiSou=0) "Grid model that provides power to the system"
  AC.ThreePhasesBalanced.Lines.Line line1(mode=Buildings.Electrical.Types.CableMode.automatic,
      l=1500,
    V_nominal=V_nominal,
    P_nominal=7*(PLoa_nominal + PSun) + PWin) "Electrical line"
              annotation (Placement(transformation(extent={{-80,10},{-60,30}})));
equation
  connect(gri.terminal, line1.terminal_n) annotation (Line(
      points={{-90,40},{-90,20},{-80,20}},
      color={0,120,120},
      smooth=Smooth.None));

Thank you for all the help

edit retag flag offensive close merge delete

Comments

@grid_designer instead of posting code from your input file, you can upload your input file to Dropbox, Google Drive, etc. and then share a link to that.

Aaron Boranian's avatar Aaron Boranian  ( 2023-03-28 10:08:00 -0500 )edit

@Aaron Boranian Done, I was not sure if this forum was okay with external links. Thanks

grid_designer's avatar grid_designer  ( 2023-03-28 10:38:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-03-30 16:39:00 -0500

I can't reproduce your problem. I downloaded your posted files, opened OpenModelica's OMEdit, opened the Modelica Buildings Library v9.1.0, opened your posted model renewable_sources.mo and simulated it.

However, you seem to confuse the use of the withinstatement. See for example https://mbe.modelica.university/ for how to organize packages.

edit flag offensive delete link more

Comments

The renewable_source.mo is an example from the library. My model is the my_microgrid.mo. I will include an updated version of that model.

grid_designer's avatar grid_designer  ( 2023-03-30 17:40:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2023-03-28 00:38:46 -0500

Seen: 63 times

Last updated: Mar 30 '23