Name | Description |
---|---|
![]() | cgs units |
![]() | Connector |
![]() | Tank with one output |
![]() | Tank with two outputs |
![]() | Pipe |
![]() | Valve |
![]() | Sink |
![]() | Flow source |
![]() | Pump with two way valves |
Type | Name | Description |
---|---|---|
Height | liqHead | Head of liquid above the point [cm] |
flow VolumeFlowRate | volFlow | Volume flow [cm3/s] |
connector liqFlow "Connector" cgsUnits.Height liqHead "Head of liquid above the point"; flow cgsUnits.VolumeFlowRate volFlow "Volume flow"; end liqFlow;
Type | Name | Default | Description |
---|---|---|---|
Boolean | volumeIsState | false | |
Boolean | hIsState | false |
Type | Name | Description |
---|---|---|
liqFlow | portBottom | |
liqFlow | portTop |
model tank "Tank with one output" liqFlow portBottom(liqHead=h); liqFlow portTop(liqHead=0); cgsUnits.Area tankSection(start=1) "Tank section"; parameter Boolean volumeIsState=false; parameter Boolean hIsState=false; cgsUnits.Height alfa1( start = 0.1); cgsUnits.Height alfa2( start = 0.1); cgsUnits.Height beta( start = 0.1); Boolean generateEvents( start = true); protected constant cgsUnits.Adim PI = 3.14159265; cgsUnits.Height h(stateSelect=if hIsState then StateSelect.always else StateSelect.never) "Liquid level inside the tank"; cgsUnits.Height hLiq "Liquid level inside the tank"; cgsUnits.Volume volume(stateSelect=if volumeIsState then StateSelect.always else StateSelect.never) "Volume of liquid inside the tank"; cgsUnits.Height tankRadius = sqrt( tankSection / PI); cgsUnits.Volume Valfa1 = 1/3*PI*alfa1*(tankRadius^2+tankRadius*beta+beta^2); cgsUnits.Volume Valfa2 = alfa2*PI*beta^2; cgsUnits.VolumeFlowRate totalFlow; equation der(volume) = if not totalFlow > 0 and not volume > 0 then 0 else totalFlow; totalFlow = portBottom.volFlow + portTop.volFlow; hLiq = min( alfa2, volume/(PI*beta^2)) + min( alfa1, max( 0, (volume-Valfa2)/(1/3*PI*(tankRadius^2+tankRadius*beta+beta^2)))) + max( 0, (volume-Valfa2-Valfa1)/(PI*tankRadius^2)); h = if generateEvents then hLiq else noEvent(hLiq); der(tankSection) = 0; der(alfa1) = 0; der(alfa2) = 0; der(beta) = 0; end tank;
Type | Name | Default | Description |
---|---|---|---|
Boolean | volumeIsState | false | |
Boolean | hIsState | false |
Type | Name | Description |
---|---|---|
liqFlow | portBottom | |
liqFlow | portTop | |
liqFlow | portMiddle |
model tank2Ouputs "Tank with two outputs" liqFlow portBottom(liqHead=h); liqFlow portTop(liqHead=0); liqFlow portMiddle(liqHead=max(0, h - hPortMiddle)); cgsUnits.Area tankSection(start=1) "Tank section"; cgsUnits.Height hPortMiddle(start=1) "Height of PortMiddle"; parameter Boolean volumeIsState=false; parameter Boolean hIsState=false; protected cgsUnits.Height h(stateSelect=if hIsState then StateSelect.always else StateSelect.never) "Liquid level inside the tank"; cgsUnits.Volume volume(stateSelect=if volumeIsState then StateSelect.always else StateSelect.never) "Volume of liquid inside the tank"; equation der(volume) = portBottom.volFlow + portTop.volFlow + portMiddle.volFlow; volume = tankSection*h; der(tankSection) = 0; der(hPortMiddle) = 0; end tank2Ouputs;
Type | Name | Default | Description |
---|---|---|---|
Real | eps | 1e-10 | |
Boolean | FIsState | false | |
Acceleration | g | 981 | Gravitatorial acceleration [cm/s2] |
Type | Name | Description |
---|---|---|
liqFlow | portP | |
liqFlow | portN |
model pipe "Pipe" liqFlow portP(volFlow=F); liqFlow portN(volFlow=-F); parameter Real eps=1e-10; parameter Boolean FIsState=false; parameter cgsUnits.Acceleration g=981 "Gravitatorial acceleration"; cgsUnits.Area a(start=1) "Cross-section of the outlet hole"; protected cgsUnits.VolumeFlowRate F(stateSelect=if FIsState then StateSelect.always else StateSelect.default); cgsUnits.Height deltah; equation F = if noEvent(deltah >= 0) then a*sqrt(2*g*deltah + eps) else -a*sqrt(-2*g* deltah + eps); deltah = max(0,portP.liqHead) - max(0,portN.liqHead); der(a) = 0; end pipe;
Type | Name | Default | Description |
---|---|---|---|
Real | eps | 1e-10 | |
Boolean | FIsState | false | |
Acceleration | g | 981 | Gravitatorial acceleration [cm/s2] |
Type | Name | Description |
---|---|---|
liqFlow | portP | |
liqFlow | portN |
model valve "Valve" liqFlow portP(volFlow=F); liqFlow portN(volFlow=-F); parameter Real eps=1e-10; parameter Boolean FIsState=false; parameter cgsUnits.Acceleration g=981 "Gravitatorial acceleration"; cgsUnits.Adim K(start=1) "Valve state: open(1)/closed(0)"; cgsUnits.Area S(start=1) "Cross-section of the valve"; protected cgsUnits.VolumeFlowRate F; cgsUnits.Height deltah; equation F = if noEvent(deltah >= 0) then K*S*sqrt(2*g*deltah + eps) else -K*S*sqrt(-2 *g*deltah + eps); deltah = portP.liqHead - portN.liqHead; der(K) = 0; der(S) = 0; end valve;
Type | Name | Description |
---|---|---|
liqFlow | port |
model sink "Sink" liqFlow port(liqHead=0); end sink;
Type | Name | Description |
---|---|---|
liqFlow | port |
model flowSource "Flow source" liqFlow port(volFlow=-flowSetPoint); cgsUnits.VolumeFlowRate flowSetPoint; equation der(flowSetPoint) = 0; end flowSource;
Type | Name | Description |
---|---|---|
liqFlow | port1 | |
liqFlow | port2 |
model pumpTwoWayValve "Pump with two way valves" // Salida gamma liqFlow port1(volFlow=-gamma*k*v); // Salida 1-gamma liqFlow port2(volFlow=-(1 - gamma)*k*v); cgsUnits.Adim gamma( min=0, max=1, start=0.5); cgsUnits.Adim k(start=1); cgsUnits.VolumeFlowRate v(start=1); equation der(gamma) = 0; der(k) = 0; der(v) = 0; end pumpTwoWayValve;