F: Flux, Flow Block.
MJMcCann-Consulting

Flow between accumulators. Multiple Modes:
Linear, radiation, square root rule, full wave rectifier, gas orifice
MJMcCann-Consulting Logo

Flux Between Accumulators.
McSimAPN allows for easy simulation of charge, heat and mass transfer by using flux between accumulators.
The flux block can be thought of as a model of a (heat, current, fluid, mass, gas) flow path between the accumulators (integrators or containers) which are keeping track of that conservable entity.
Prudent use of analogue computers and steps to eliminate errors in coding ODE solutions led me to make sure that each flux was calculated once only and that result was used directly into the summation of the integrators (be they analogue or computational).
The flux block detects the level (e.g. the voltage or temperature, head of liquid)) at its ends and calculates the flux (rate of flow) that will result. It then moves that flux from the An accumulator to the Bn accumulator with appropriate recognition of integrators or containers or other types.
For containers the effect is achieved by directly adding in the flux (a rate) times the time step (Delt)
For integrators the flux is put in the pp variable and the integrator includes it with its own computed rate of change.
For other blocks, no changes are made so they are, in effect, considered as being able to absorb or deliver any amount of the flowing entity. In electrical terms, they have zero source impedance.

Switch on/off
McSimAPN blocks normally just stop calculating and freeze at the current output level when switched OFF, but the Flux block goes to zero flux. This means it will behave like a switch or a stop-cock in a circuit; OFF means no flow. Because the calculated flux appears as its output, it can be used like any other block to define a value AND also give the option of switching that value on or off. It doesn't have to represent a flux. Use a constant for the "aa" value, unity for the "cc" value and the output will be a switchable output of "aa" or zero.

Variants
Av, Bv etc are the output values of blocks at An, Bn etc.
The flux is calculated and an extra flux, Dv+dd, can be added in if needed.
The total calculated flux is also available as the output of the block, Vn. It can therefore be used as an extra flux in another link, or used directly in some other calculation if An and Bn do not identify accumulators.

The identified modes are:
0: Linear: The difference in level between (Av+aa) and (Bv+bb) is multiplied by the conductance (Cv+cc) to define the flow rate.
1: Radiation: The difference between the 4th powers of (Av+aa) and (Bv+bb) is multiplied by the area*emissivity product, (Cv+cc), and the Stephan Boltzman constant (in SI units) to give the heat flux. TEMPERATURES ARE ABSOLUTE degK.
The computation is organized to avoid taking differences of 4th powers which can lead to rounding errors for large, similar temperatures
2: Square Root Law: The flow is assumed driven by the square root of the pressure differential between the An and Bn connections. This can work directly for mass flow rate between (the head level in) tanks, but may be used in other cases by recognising the option of using the calculation simply to evaluate the flow rate, as Vn, and adding it in to accumulators (integrators usually) in other ways. Because the square root rule leads to having avery high sensitivity in flux for very small pressure differences, which is rather unrealistic, the option is allowed to put in a little extra pressure drop term, via the Pv value, that modifies the relationship and removes both the unrealism and the problem it can cause of making dynamic systems very stiff and potentially computationally unstable. See Mathcad analysis of flux models
3: Full wave rectification: The flow goes from An to Bn when the absolute value of the voltage at An exceeds the voltage at Bn.
Beware that this can be used to calculate what is happening in magnitude terms, but the containers/capacitors (or integrators) on the rectified side are, in a real system, running with different ground/neutral levels from those on the source side. Don't directly cross connect by flux links in McSimAPN to link the power source side with the rectified side.
4: Gas Flow Orifice: The mass flow is calculated assuming adiabatic expansion through orifice of area Cv between pressure Av and pressure Bv, with upstream temperature Dv and molecular mass Pv. Gamma is assumed the same in all cases at 1.4. See Mathcad analysis of flux models

F block Code
Procedure ActivateF(ii:integer); //calculate FLUX RATE between An Bn, add in extra Dv and
//put into the pp values of -An +Bn if Integrators or for Containers move a quantity in time Delt.
// but note Dv is used for upstream temperature in mode 4,
// Pv is used for low pressure modification in mode 2 and for molecular mass in mode 4
// 0: linear Flux = (A+aa -{B+bb})*(C+cc) + (D+dd).
// 1: radiation Flux= ((A+aa)^4 -(B+bb)^4)*(C+cc)*StBoCo + (D+dd). DegC or DegK, C=em*area
// 2: fluid flow where flow is proportional to square root of pressure drop.
// 3: rectifier (full wave)
// 4: gas flow may choke with sonic flow at orifice
// if switched off, then NO flux. Device behaves like a stop-cock or switch.
var Av,Bv,Cv,Dv, Pv, ratio, Po :real;
begin with B[ii] do begin
if OnOff<=0 then begin Vn:=0; EXIT end;
Av:=B[An].Vn+aa; Bv:=B[Bn].Vn+bb; Cv:= B[Cn].Vn+cc; Dv:=B[Dn].Vn+dd; Pv:=abs(B[Pn].Vn +pp);
case State of
0: Vn:=(Av-Bv)*Cv + Dv; //linear, conduction, current in conductance
1: Vn:=(Av*Av+Bv*Bv)*(Av+Bv)*(Av-Bv)*StBoCo*Cv + Dv; //radiation
2: Vn:= sign(Av-Bv)*Cv*(sqrt(abs(Av-Bv)+Pv)-sqrt(Pv) )+ Dv; //flow driven by sqrt of pressure drop
3: Vn:=max(0,(abs(Av)-Bv)*Cv) + Dv; //big +/-A causes pos flux into Bn
4: begin // gas flow, may choke for low P/Po ratio, Dv is To, Pv is mol-mass, Cv is area
ratio:=Bv/Av; Po:=Av; // base case for Av>Bv but swap if Bv bigger...
if Bv>Av then begin ratio:=Av/Bv; Po:=Bv end;
ratio:=ratio*ratio; ratio:=ratio*ratio; ratio:=ratio*ratio; //eighth power
Vn:=Cv*Po*sqrt(Pv/Dv)*7.509407e-3*(1-ratio);
end;
end{case};
if B[An].Ty = 'I' then B[An].pp:=B[An].pp-Vn;
if (B[An].Ty = 'C') and (An> LastSystemBlock) then B[An].Vn:=B[An].Vn-Vn*Delt;
if B[Bn].Ty = 'I' then B[Bn].pp:=B[Bn].pp+Vn;
if (B[Bn].Ty = 'C') and (Bn> LastSystemBlock) then B[Bn].Vn:=B[Bn].Vn+Vn*Delt;
end{with}
end;

MJMcCann-Consulting

Help Index:
Index/Search

Background
Simulation Concepts
Continuous Systems
Discrete Systems
McSimAPN Structure
McSimAPN Operation

Using McSimAPN
Start McSimAPN
Save Model,data
Create Blocks
Run-Hold-Reset
Link Excel+VBA

PetriNet Block Types
A activity/action
B belt conveyor
C container/constant
D diverter(random)

Analogue Block Types
E exponents
F flux/flow
G function Generator
H hysteresis
I integrator
J inductor
K logic element
L logarithms
M memory
N note/label
O oscilloscope/graph
p not assigned
Q quantizer/rounding
R relay on/off
S sin/asin/atan
T timer/clock
U user link Excel
V visual voltmeter
W sWitch selector/MUX
X multiply
y not assigned
Z random (fuZZ)
& signed summation
% division/difference
@ access/move values

Invitation. McCann can help if you have a design or operational problem that needs some technical support that is outside your team's experience, some quantitative assessment of what is really the cause of the difficulties, some design alternatives or just a fresh look by an intelligent interrogator.
If you have a problem with the behaviour of a market sector, plant, process or item of equipment and would like to get a quantitative handle on it to improve yield or optimise performance, then contact us. We are always ready to give a little time to discuss a new puzzle, in confidence, of course. We'll only worry about fees when we have some defined work. We can be flexible about how we work with you.
Top
MJMcCann-Consulting,
POB 902,
Chadds Ford PA
19317 USA.
T: 1 302 654-2953
F: 1 302 429 9458
E: mjmccann@iee.org
Request. Please let us know how you found this software and your interests by sending an email to mjmccann@iee.org Thank you Date: 2012.02.26
File: f.htm