SUBROUTINE TYPE64 (TIME,XIN,OUT,T,DTDT,PAR,INFO,ICNTRL,*) C*********************************************************************** C* Copyright ASHRAE. Toolkit for HVAC System Energy Calculations C*********************************************************************** C* SUBROUTINE: VLV3MDET C* C* LANGUAGE: FORTRAN 77 C* C* PURPOSE: Calculates the performance of a three-way C* mixing valve. Determines valve flows for C* given inlet pressures, outlet pressure and C* valve position. The routine can model a C* diverting valve if PLvg > PEnt, resulting C* in negative flow rates. C*********************************************************************** C* INPUT VARIABLES DESCRIPTION(UNITS) SAMPLE VALUES C* XIN(1) P1Ent Pressure of fluid entering valve port #1(Pa) 126336.0 C* XIN(2) P2Ent Pressure of fluid entering valve port #2(Pa) 126336.0 C* XIN(3) PLvg Pressure of fluid leaving valve(Pa) 101325.0 C* XIN(4) Pos1 Valve position for port #1(0=closed,1=open)(-) .50 C* C* OUTPUT VARIABLES C* OUT(1) M1Ent Mass flow rate entering valve valve port #1(kg/s) 1.515 C* OUT(2) M2Ent Mass flow rate entering valve valve port #2(kg/s) 1.515 C* OUT(3) MLvg Mass flow rate leaving valve(kg/s) 3.03 C* OUT(4)ErrStat Error status indicator, 0=ok, 1=error(-) 0.0 C* C* PARAMETERS C* PAR(1) ResOp1 Flow resistance coefficient of open port#1(1/kgm) 2779.0 C* PAR(2) ResOp2 Flow resistance coefficient of open port#2(1/kgm) 2779.0 C* PAR(3) WtFac1 Weighting factor for port #1 characteristic(-) 1.0 C* PAR(4) WtFac2 Weighting factor for port #2 characteristic(-) 1.0 C* WtFac = 0 : exponential characteristic C* WtFac = 1 : linear characteristic C* 0 < WtFac < 1 : intermediate characteristic C* PAR(5) LeakP1 Leakage parameter for port #1, ratio of flow(-) .01 C* through closed valve to flow through open valve C* at fixed pressure differential C* PAR(6) LeakP2 Leakage parameter for port #2, ratio of flow(-) .01 C* through closed valve to flow through open valve C* at fixed pressure differential C*********************************************************************** C MAJOR RESTRICTIONS: Three way valve modeled as two separate C two-way valves. C C DEVELOPER: Michael J. Brandemuehl, PhD, PE C University of Colorado at Boulder C C DATE: January 1, 1992 C C INCLUDE FILES: vlv3.inc C SUBROUTINES CALLED: VLVMDET C FUNCTIONS CALLED: None C C REVISION HISTORY: None C C REFERENCE: Clark, D.R. 1985. HVACSIM+ building C systems and equipment simulation program: C Reference Manual. NBSIR 84-2996, National C Institute of Standards and Technology, C Washingtion, D.C. C*********************************************************************** C INTERNAL VARIABLES C port1 Parameter array index for port #1 parameters C port2 Parameter array index for port #2 parameters C pos2 Valve position of port #2 C*********************************************************************** DOUBLE PRECISION XIN, OUT INTEGER ErrStat, INFO, IOPT, NI, NP, ND REAL MLvg,PAR DIMENSION XIN(4),OUT(4),PAR(6),INFO(15) CHARACTER*3 YCHECK(4), OCHECK(4) DATA YCHECK/'PR3','PR3','PR3','DM1'/ DATA OCHECK/'MF2','MF2','MF2','DM1'/ ErrStat = 0 IOPT = -1 NI = 4 !CORRECT NUMBRE OF INPUTS NP = 6 !CORRECT NUMBER OF PARAMETERS ND = 0 !CORRECT NUMBER OF DERIVATIVES P1ENT = XIN(1) P2ENT = XIN(2) PLVG = XIN(3) POS1 = XIN(4) RESOP1 = PAR(1) RESOP2 = PAR(2) WTFAC1 = PAR(3) WTFAC2 = PAR(4) LEAKP1 = PAR(5) LEAKP2 = PAR(6) IF (INFO(7).EQ.-1) THEN CALL TYPECK(IOPT,INFO,NI,NP,ND) C CHECKS TO SEE IF USER'S INFO MATCHES CORRECT NUMBERS CALL RCHECK(INFO,YCHECK,OCHECK) C CHECKS TO SEE IF INPUT AND OUTPUT UNITS MATCH ENDIF C2*** A three-way valve or damper is modeled as two separate two-way C2*** valves. The valve model is called for each flow port. C1*** Calculate the flow through port #1 given valve characteristics, C1*** pressure difference, and valve position. CALL VLVMDET (RESOP1,WTFAC1,LEAKP1,P1Ent,PLvg,Pos1,M1Ent,ErrStat) C1*** Calculate the flow through port #2 given valve characteristics, C1*** pressure difference, and valve position. pos2 = 1-Pos1 CALL VLVMDET (RESOP2,WTFAC2,LEAKP2,P2Ent,PLvg,pos2,M2Ent,ErrStat) C1*** Calculate leaving flow from entering flows. MLvg = M1Ent + M2Ent OUT(1) = M1ENT OUT(2) = M2ENT OUT(3) = MLVG OUT(4) = ERRSTAT RETURN 1 END SUBROUTINE VLVMDET (RESOPEN,WTFACTOR,LEAKPAR,PEnt, & PLvg,Pos,M,ErrStat) C*********************************************************************** C* Copyright ASHRAE. Toolkit for HVAC System Energy Calculations C*********************************************************************** C* SUBROUTINE: VLVMDET C* C* LANGUAGE: FORTRAN 77 C* C* PURPOSE: Calculates the performance of a valve or C* damper. Flow is determined as a function C* of inlet pressure, outlet pressure and C* valve position. C*********************************************************************** C* INPUT VARIABLES: C* PLvg Pressure of fluid leaving valve (Pa) C* PEnt Pressure of fluid entering valve (Pa) C* Pos Valve position (0=closed,1=open) (-) C* C* OUTPUT VARIABLES: C* M Mass flow rate through valve (kg/s) C* ErrStat Error status indicator, 0 = ok, 1 = error (-) C* C* PARAMETERS C* ResOpen Flow resistance coefficient at full open (1/kg m) C* WtFactor Weighting factor for valve characteristic (-) C* WtFactor = 0 : exponential characteristic C* WtFactor = 1 : linear characteristic C* 0 < WtFactor < 1 : intermediate characteristic C* LeakPar Leakage parameter, ratio of flow through (-) C* closed valve to flow through open valve C* at fixed pressure differential C*********************************************************************** C MAJOR RESTRICTIONS: Pressure drop proportional to square of C flow rate. C C DEVELOPER: Shauna Gabel C Michael J. Brandemuehl, PhD, PE C University of Colorado at Boulder C C DATE: January 1, 1992 C C INCLUDE FILES: vlv.inc C SUBROUTINES CALLED: None C FUNCTIONS CALLED: None C C REVISION HISTORY: None C C REFERENCE: Clark, D.R. 1985. HVACSIM+ building C systems and equipment simulation program: C Reference Manual. NBSIR 84-2996, National C Institute of Standards and Technology, C Washington, D.C. C*********************************************************************** C INTERNAL VARIABLES: C rlinear Characterizes linear resistance (1/kg m) C rExp Characterizes exponential resistance (1/kg m) C resistCoef Flow resistance coefficient relating (1/kg m) C flow to pressure drop C deltaP Pressure drop across the valve (Pa) C small Small number used in place of zero C*********************************************************************** INTEGER ErrStat REAL leak,M,RESOPEN,WTFACTOR,LEAKPAR DATA small/1.E-6/ ErrStat = 0 C2*** Check to ensure non-zero leakage parameter leak = MAX ( LeakPar,small) C1*** Calculate the flow resistance coefficient as the weighted average C1*** of linear and exponential valves. rLinear = 1./(((1-leak)*Pos+leak)**2) rExp = leak**(2*(1-Pos)) resistCoef = ResOpen*(WtFactor*rLinear+(1-WtFactor)*rExp) C1*** Calculate the flow rate through the valve C2*** SIGN( SQRT(ABS(x)), x) allows negative M for negative deltaP deltaP = PEnt - PLvg M = SIGN(SQRT(ABS(deltaP)/resistCoef),deltaP) RETURN END