Message Boards Message Boards

0
|
5184 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Creating Connection : How to specify the connection port on the Icon ?

Posted 10 years ago

Greetings,

I am new to Modelica and SystemModeler. I thought if I create new components from scratch, I will learn better. I am trying to create a simple orifice component. I started with creating a fluid connector. When I insert the component into a model, I cannot connect it, in other words, I don't know how to define the ports connection on the icons and diagrams of the component/connector. What is the code responsible for that ?

POSTED BY: Mohamed Mahmoud
3 Replies
Posted 10 years ago

I think I found the mistake. I didn't make the annotation for the FluidPort. There's a difference between the annotation for the whole interface and for the ports themselves. Each port should have a separate annotation like the code below. I copied the annotations from the Fluid library since I don't really understand how it works.

FluidPort_a port_a annotation(Placement(transformation(extent={{-110,-10},{-90,10}}, rotation=0)));
FluidPort_b port_b annotation(Placement(transformation(extent={{110,-10},{90,10}}, rotation=0), iconTransformation(extent={{110,-10},{90,10}})));

Thanks Johan for your help anyway :)

POSTED BY: Mohamed Mahmoud
Posted 10 years ago

Thanks Johan for your reply. I took a look at the guide. It seems to me that there is a default option that is not working for me !

Let me explain a little bit what I'm trying to do. I am trying to create a Hydraulics Package similar to the one found in Modelica 3.1.

I copied the types from the standard library.

I started with creating a Fluid Port :

connector FluidPort "Interface for quasi one-dimensional fluid flow in a piping network (incompressible or compressible, one or more phases, one or more substances)"
  flow Hydraulics.Media.Interfaces.Types.MassFlowRate m_flow "Mass flow rate from the connection point into the component";
  Hydraulics.Media.Interfaces.Types.AbsolutePressure p "Thermodynamic pressure in the connection point";
  annotation(Icon(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10}), graphics={Ellipse(visible=true, fillColor={255,255,255}, lineThickness=2, extent={{-100.0,-100.0},{100.0,100.0}})}));
end FluidPort;

Then I created a FluidPorta and FluidPortb

connector FluidPort_a "Generic fluid connector at design inlet"
  extends Hydraulics.Interfaces.FluidPort;
  annotation(Diagram(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10}), graphics={Ellipse(visible=true, fillColor={0,0,255}, fillPattern=FillPattern.Solid, extent={{-40.0,-40.0},{40.0,40.0}}),Text(visible=true, lineColor={0,127,0}, extent={{-160.0,50.0},{40.0,110.0}}, textString="%name", fontName="Arial")}), Icon(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10}), graphics={Ellipse(visible=true, fillColor={0,0,255}, fillPattern=FillPattern.Solid, extent={{-100.0,-100.0},{100.0,100.0}})}));
end FluidPort_a;

Then an Interface:

partial model PartialTwoPort
  FluidPort_a port_a;
  FluidPort_b port_b;
  annotation(Icon(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10}), graphics={Ellipse(visible=true, origin={-100.0,0.0}, fillColor={0,0,255}, fillPattern=FillPattern.Solid, extent={{-10.0,-10.0},{10.0,10.0}}),Ellipse(visible=true, origin={100.0,0.0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, extent={{-10.0,-10.0},{10.0,10.0}})}), Diagram(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10}), graphics={Ellipse(visible=true, origin={-100.0,0.0}, fillColor={0,0,255}, fillPattern=FillPattern.Solid, extent={{-10.0,-10.0},{10.0,10.0}}),Ellipse(visible=true, origin={100.0,0.0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, extent={{-10.0,-10.0},{10.0,10.0}}),Polygon(visible=true, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid, points={{50.0,-90.0},{20.0,-80.0},{20.0,-100.0},{50.0,-90.0}}),Line(visible=true, points={{-60.0,-90.0},{20.0,-90.0}})}));
end PartialTwoPort;

At this stage, the "Connection Line Tool" should detect the ports, in other words, the cursor should change to thick plus sign when I click on the port. But this doesn't happen ! The guide didn't mention anything about it, so I assume it should automatically detect the port.

I am still trying to create a component. I am not trying to create a custom component from other components so I can use "Create Connection".

Correct me please if I'm missing something ?

POSTED BY: Mohamed Mahmoud
Posted 10 years ago

Hi Mohamed,

I'd recommend you to take a look at the IntroductoryExamples package. It is bundled with SystemModeler. There's a guide called "Getting Started" that you can reach from the Help menu. Look at chapter 7 and especially 7.2.1. I hope that helps!

Johan

POSTED BY: Johan Rhodin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract