Help - Search - Members - Calendar
Full Version: Bizarre connect construction
Modelica Forum > Modelica > Modelica
Hannes
Hello! rolleyes.gif

I'm currently modeling an ideal hydraulic swap device. This means, that I have a Y-crossing possessing the ports port_a, port_b and port_c. They are all of type Port_SeaWater. Let n be the boolean control signal, then port_a should be connected either to port_b or (XOR) to port_c. The respective port that's not connected is therefore connected to a dead end called port_stop.

The hydraulic connector is:

++++++++++++++++++++++++++++++++++++++
connector Port_SeaWater "Interface for a streaming salty seawater (binary fluid with water and salt)
OUT OF or INTO a hydraulic device"
import waterLib = PV_RO_components.Hydraulics.Water;
replaceable package Water = waterLib.PartialSeaWater;
///////////////////////////////////////////////////////////////////
Water.StaticPressure p "Static non-gauge pressure";
flow Water.MassFlowRate dotM_flow "Total mass flow rate";
Water.SpecificEnthalpy h "Mass-specific enthalpy";
flow Water.EnthalpyFlowRate dotH_flow "Enthalpy flow rate";
Water.MassFraction X_s "Ratio: Mass of salt per total mass";
flow Water.MassFlowRate dotM_flow_s "Mass flow rate of salt";
end Port_SeaWater;
++++++++++++++++++++++++++++++++++++++

As to my original question, I try to realize my aim by the following construction:

++++++++++++++++++++++++++++++++++++++
if (n == false) then
connect(port_b, port_a);
connect(port_c, port_stop);
else
connect(port_b, port_stop);
connect(port_c, port_a);
end if;
++++++++++++++++++++++++++++++++++++++

But unfortunately, I get an error-message:

++++++++++++++++++++++++++++++++++++++
Check of PV_RO_components.Hydraulics.Devices.Mixture.WorkExchangers.ClarkPump.HydraulicSwap:
Error: Failed to expand block containing connect:
equation
if (n == false) then
connect(port_b, port_a);
connect(port_c, port_stop);
else
connect(port_b, port_stop);
connect(port_c, port_a);
end if;
The model contained invalid connect statements.
Check aborted.
ERROR: 1 error was found
++++++++++++++++++++++++++++++++++++++

Does anybody know, WHETHER my construction is forbidden dry.gif and if so, WHY it is forbidden blink.gif ? Maybe anybody can tell me an alterrnative simple solution...


Thanks a lot,
Hannes
wagner
Hello Hannes,

I also tried to use equations inside an if statement and it didn't work. I couldn't find anything about this in Modelica language specification. Maybe it's allowed in the Modelica language but it is not supported in Dymola, I don't know.

The workaround for this would be to manually set the connector variables equal inside the if block:

CODE

if (n) then
  port_b.p=port_a.p;
  port_b.dotM_flow=-port_a.dotN_flow;
  ....

  port_c.p=port_stop.p;
  port_c.dotM_flow=-port_stop.dotN_flow;
  
else
//vice vers
end if;


This doesn't look that nice anymore but it worked in my models. Maybe you need to introduce a switching dynamic to make the flow changes differentiable.

Regards

Florian
Carsten
Hello Hannes,

i think you problem is, that n is an input signal and no parameter. The connect equation highly influence the model translation and index reduction. Hence, changing connect equations, means a change in model structure. This is not legal in Modelica, even if it is not written in the Modelica Specification 2.2, but in 3.0 it is (http://www.modelica.org/documents/ModelicaSpec30.pdf) page 85.

The tool Mosilab from Frauenhofer offers some possibilities to change model structure dynamiclly, but not 100% Modelica conform.

What you should do to resolve you problem, is to write a component with the three ports. Here you can include flow equations depending on input signals:

QUELLTEXT

if n then
  m_flow_AC = kNom * dpAC;
  m_flow_AB = kZero * dpAB;
else
  m_flow_AC = kZero * dpAC;
  m_flow_AB = kNom * dpAB;
end if;


Regards Carsten
Hannes
Okay, I agree with your answer. I already tackled the problem quite similar as you said in your last advice here. Actually I'm thinking about how to redirect a hydraulic flow from one direction AB to another AC while completely closing the old one AB. My first idea was to realisze the connections by connect-statements as mentioned above and then re-connect them when necessary. But as this didn't work, I wrote a kind of two-way-valve (I don't know the exact english term). This is a "Y" of which two branches a blocked in a complementary way. But - as always - I run into the next problem: I had to stop an inertial flwo, which normale take more time than zero. So boom, a kind of shock wave backwards would would the result in reality. I tried dampers, I tried elastic valve membranes, all was quite strange and too complicated to be right. There's another item in this forum that tackles this topic.

Mayby I should completely ignore storage of momentum (dotM*L).

Finally, I didn't solve the problem till now.

Hannes
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.