3

Tested with:

MSL Versions:

  • 3.2.1, 2013-08-14, build 2 (2013-08-14 08:44:41Z)
  • 3.2.1, 2013-08-14, build 4 (2015-09-30 09:15:00Z)

Below is a model with 4 components:

  1. Mass flow source (M_bound)
  2. AbruptAdapter (abruptAdapter)
  3. Dynamic Pipe (pipeSmall)
  4. Pressure Source (P_bound)

Two connection cases of the model are also contained in the equation section:

Case #1: M_bound -> abruptAdaptor -> pipeSmall -> P_bound

Case #2: M_bound -> pipeSmall -> abruptAdaptor -> P_bound

Summary: Case #1 simulates fine but Case #2 fails. The error generated is shown below:

The following error was detected at time: 0

Model error - division by zero: (data.zeta1) / ((if data.zeta1_at_a then rho_a_des*A_a^2 else rho_b_des*A_b^2)) = (0.402964) / (0)

The stack of functions is:
Modelica.Fluid.Fittings.BaseClasses.QuadraticTurbulent.pressureLoss_m_flow_totalPressure
Modelica.Fluid.Fittings.BaseClasses.QuadraticTurbulent.pressureLoss_m_flow_totalPressure(
 -pipeBig.port_b.m_flow, 
abruptAdaptor.state_a.d, 
abruptAdaptor.state_b_des.d, 
abruptAdaptor.state_b.d, 
abruptAdaptor.state_a_nondes.d, 
abruptAdaptor.data, 
abruptAdaptor.m_flow_small)
First evaluation failed for non-linear solver.

Question: Why does Case #2 fail and recommendations on how to fix it? Any insight would be great. It may even be a bug in the AbruptAdaptor component.

Model Code

model AbruptAdaptor_1Pipe

  replaceable package Medium = Modelica.Media.Water.StandardWater;

  inner Modelica.Fluid.System system;

  Modelica.Fluid.Sources.Boundary_pT P_bound(
    redeclare package Medium = Medium,
    nPorts=1,
    p=system.p_ambient,
    T=M_bound.T);

  Modelica.Fluid.Sources.MassFlowSource_T M_bound(
    redeclare package Medium = Medium,
    m_flow=1,
    T=300,
    nPorts=1);

  Modelica.Fluid.Fittings.AbruptAdaptor abruptAdaptor(
    redeclare package Medium = Medium,
    diameter_a=1,
    diameter_b=0.5,
    m_flow_nominal=M_bound.m_flow,
    m_flow_start=M_bound.m_flow);

  Modelica.Fluid.Pipes.DynamicPipe pipeSmall(
    redeclare package Medium = Medium,
    T_start=M_bound.T,
    m_flow_start=M_bound.m_flow,
    length=1,
    diameter=0.5,
    modelStructure=Modelica.Fluid.Types.ModelStructure.av_b); // switch to av_vb with case #2

equation 

  // Case #1
  connect(M_bound.ports[1],abruptAdaptor.port_a);
  connect(abruptAdaptor.port_b,pipeSmall.port_a);
  connect(pipeSmall.port_b,P_bound.ports[1]);

  // Case #2
  //connect(M_bound.ports[1],pipeSmall.port_b);
  //connect(abruptAdaptor.port_b,pipeSmall.port_a);
  //connect(abruptAdaptor.port_a,P_bound.ports[1]);

  annotation (uses(Modelica(version="3.2.1")));
end AbruptAdaptor_1Pipe;
Scott G
  • 2,194
  • 1
  • 14
  • 24
  • Two comments: You are using an old MSL (build 2), the current build 4 is closer to the language specification. Second comment: The DynamicPipe is using a staggered grid with alternating volumes and flow elements. Try changing the `modelStructure` on the `Advanced` parameters tab, the system of equations might become easier to solve. But your error may just as well be completely unrelated... – matth Mar 30 '16 at 06:49
  • In case #2 the mass flow direction through the components is reversed. Is that on purpose or did you actually mean to switch the order of pipe/adaptor? – Rene Just Nielsen Mar 30 '16 at 07:52
  • With Dymola you will probably not see too much difference ebetween build 2 and 4. Being stricter/closer to the language specification mainly helps other tools like OpenModelica and JModelica (you added these tags also). Still, you might consider updating to Dymola 2016 FD01, which is currently the latest version. – matth Mar 30 '16 at 12:38
  • Sorry I posted before I meant too: @matth : 1. I'm using Dymola 2016 which loads build 2 but I've compared the code between the versions and saw no differences on AbruptAdapter. 2. I'm aware of the staggered nature of DynamicPipe. That does not seem to be the issue with this problem. I'll try to figure out how to update to the latest build. I also attempted to use jModelica and got the same error. – Scott G Mar 30 '16 at 12:39
  • @ReneJustNielsen : The flow direction was on purpose. The device is supposed to be compatible for both directions. If you switch the order (i.e., swap pipeSmall.port_b and abruptAdaptor.port_a in the connections) the model will work. However if you place a pipe on either side of the component the model fails with the afore mentioned error. – Scott G Mar 30 '16 at 12:42
  • @matth : I tested it with build 4 and observed the same error. – Scott G Mar 30 '16 at 12:52

1 Answers1

1

your staggered grid is fine, you set volumes where you had to. Don't worry, it's not your fault, is a debug, I tried to use it several times, and it always fails in one of the ways (I don't know the position of your adaptor, but it doesn't really matter). You can always use orifices where you define the relations dp(Areas_rate), avoiding reversal flows in both cases, so connecting two volumes before and after the orifices (like two valves in parallel). That should work.

victor.aer
  • 106
  • 5