Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Connectors with temperature and flow

Connectors with temperature and flow

Hi.

I am trying to build a model of a hot water system in OMEdit but I cant seem to make the connectors to give the models both the flow and the temperature (or enthalpy) of the component it is connected too.

I want the out port of one component that i connect with the in port of another component to automatically have the same (opposite) flow and the same temperature but I cant seem to get the stream connectors to do the job.

Could anyone make an example where there are 2 sources of water that goes into a component that mixes the flows and then outputs a single flow (with the combined temperature and flow from the sources) that goes into a sink that gets the temperature of the output from the mixer. The pressure is irrelevant in the models I am trying to create.

Im using the latest nightly build on windows if that matters in any way.

Re: Connectors with temperature and flow

may I ask how your connector is defined? are you using "stream"-prefix for the temperature? can you post the code?

Re: Connectors with temperature and flow

Hi
I have quiet the same problem with my modeling
Could you please help me solve this problem ?
Thanks a lot
Cyril


package Nodes
  connector FlowInlet
    Modelica.SIunits.Temperature T;
    flow Modelica.SIunits.VolumeFlowRate q;
  end FlowInlet;
  model HEXDuctSection
    FlowInlet Port1,Port2;
  equation
    Port1.q - Port2.q = 0;
    // non compressible fluid
    Port1.T - Port2.T = 1;
    // T diminution per element
  end HEXDuctSection;
  partial model HEXShell
    FlowInlet A1(T = 50, q = 200),A2;
    //Declaration of Inlet conditions
  end HEXShell;
  model HEXn
    extends HEXShell;
    parameter Integer n(start = 3);
    HEXDuctSection DuctA[n];
  equation
    connect(A1,DuctA[1].Port1);
    for i in 1:n - 1 loop
    connect(DuctA[i].Port2,DuctA[i + 1].Port1);

    end for;
    connect(DuctA[n].Port2,A2);
  end HEXn;
end Nodes;

Re: Connectors with temperature and flow

Ok, to be honest, I don't really understand what you did there. Since the model doesnt run (I'm using Wolfram System Modeler), I don't really know what you are trying to simulate nor how to fix it.
What I see is: You're using flow and potential variables in your connector. Flow variables in Modelica are positive for flow inside a model and negative for flow outside a model. So in your model HEXDuctSection, I guess you mean, that the inside flow is same as the outside flow, so it would have to be Port1.q+Port2.q=0.
With potential variables this is different, they are always positive, so Port1.T-Port2.T=1 means, that the inside Temperature is 1 kelvin (or whatever unit) higher than the outgoing, so this element is cooling. Is this the way it should be?

Re: Connectors with temperature and flow

Hi SKD,
I think that you have well understand what I want to do. I fix the volume flow rate  (q=200) and the temperature (T=50°C) at the inlet Heat Exchanger with the connector A1. The exchanger is divided in n elements. For each element I implement law for q and T variations (q = constant) and a temperature difference of 1K (cooling effectively). I want to know the volume flow rate and the temperature at the outlet of the HX (connector A2).
My model works with potential (T) but fails when I introduce the flow q.
Thank you for your help.
Cyril

Re: Connectors with temperature and flow

Ok,
I'm still very new to modelica too although I spent a lot of time with it the last 2 months.
I tried a bit around with the model. The problem is that the numbers of variables and equations don't match.
I got the model to work when I put a component in front of it (dada) which has definded q and t and another component behind of it dada2 which basically does nothing current/smile
After that the numbers matched and I could simulate. I also removed the q and T equations IN your model.
Also I changed your q-equation as I said  before. Heres the model:

package Nodes
  connector FlowInlet
    Real T;
    flow Real q;
  end FlowInlet;

  model HEXDuctSection
    FlowInlet Port1;
    FlowInlet Port2;
  equation
    Port1.q + Port2.q=0;
    Port1.T - Port2.T=1;
  end HEXDuctSection;

  partial model HEXShell
    FlowInlet A1,A2;
  end HEXShell;

  model HEXn
    extends HEXShell;
    parameter Integer n(start=3);
    HEXDuctSection DuctA[n];
  equation
    connect(A1,DuctA[1].Port1);
    for i in 1:n - 1 loop
      connect(DuctA[i].Port2,DuctA[i + 1].Port1);
    end for;
    connect(DuctA[n].Port2,A2);
  end HEXn;

end Nodes;
model dada
  Nodes.FlowInlet b;
equation
  b.T=50;
  b.q=500;
end dada;
model dada2
  Nodes.FlowInlet a;;
end dada2;

model testneu
  Nodes.HEXn HEXn1 ;
  dada2 dada21;
  dada dada1;
equation
  connect(dada1.b,HEXn1.A1);
  connect(HEXn1.A2,dada21.a);
end testneu;

This is not meant to be a fixed model, it is just kind of workaround and maybe gives you some help integrating your code in the simulation you want to run. I hope it helps.
I'd also be very interested in other solutions for the problem.

By the way: I also often have problems with the numbers of equations and variables. Since I often don't have equal numbers of flow and potential variables my models often have problems and I can't simulate the single components. But since I simulate models containing of more than one component it usually equals out somehow.
I know that this is "bad modeling" but often I don't find another way to do it.

Re: Connectors with temperature and flow

Thank you very much SKD,
The model runs well now.
Cyril

Re: Connectors with temperature and flow

Hi,
i'm also seeking for examples, where a mixer (see Rorin's threadstart) lets
2 streams of water at different temperatures combine to a single stream at a controlled temperature.
I only see a solution using 2 valves, which are "mechanically" reziprocal connected
and actuated by a P(ID)-controller.
Application-example; woodgasification-boilers for homeheating need a so called
return temperature raising facility to run at spezified temperatures.
I'm trying to insert this feature into modelica.heating_system-eample.
Max

Re: Connectors with temperature and flow

I don't have the time untill next week, but you could have a look at the built-in examples with the tanksystem, there you have another controll system.

There are 0 guests and 0 other users also viewing this topic
You are here: