- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » "With Modelica" & Connectors with...
"With Modelica" & Connectors with Annotations
"With Modelica" & Connectors with Annotations
Hey Guys,
I'm following an exercise verbatim and have some a few instances of the code that need some clarification. The code begins with "Within Modelica.HeatTransfer; and then it goes on to declare the file as a package. This was confusing, for when you start a new modelica class, there is no option to choose "Within" type of class. I'm not exactly sure what this command does and if one is supposed to add this to their script in the beginning just after declaring class type.
I also got a couple of errors due to lack of semicolons, but once again, I was copying the code verbatim and adding the semicolons where they want me to does not fix the code errors. So I'm kind of thinking it is ultimately linked to the improper declaration of the "Within" type of Modelica class.
Below I have copied a sample of my code I'm having issues with.
Code:
within Modelica.Thermal.HeatTransfer;
package Interfaces "Connectors and partial models"
partial connector HeatPort "Thermal port for 1-dim. heat transfer"
Modelica.SIunits.Temperature T "Port temperature";
flow Modelica.SIunits.HeatFlowRate Q_flow
"Heat flow rate (positive if flowing from outside into the component)";
end HeatPort;
connector HeatPort_a "Thermal port for 1-dim. heat transfer (filled rectangular icon)"
extends HeatPort;
annotation(...,
Icon(coordinateSystem(preserveAspectRatio=true,
extent={{-100,-100},{100,100}}),
graphics={Rectangle(
extent={{-100,100},{100,-100}},
lineColor={191,0,0},
fillColor={191,0,0},
fillPattern=FillPattern.Solid)}));
end HeatPort_a;
connector HeatPort_b "Thermal port for 1-dim. heat transfer (unfilled rectangular icon)"
extends HeatPort;
annotation(...,
Icon(coordinateSystem(preserveAspectRatio=true,
extent={{-100,-100},{100,100}}),
graphics={Rectangle(
extent={{-100,100},{100,-100}},
lineColor={191,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}));
end HeatPort_b;
end Interfaces;
- KFung
- 27 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » "With Modelica" & Connectors with...