1、Poppet valve code in Amesim/* Submodel PNAP031 skeleton created by AME Submodel editing utilityven. 19. oct. 11:25:23 2012 */#include #include #include #include ameutils.h/* *TITLE : PNAP031-DESCRIPTION :PNAP031 is a submodel of the one-dimensional motion of a pneumaticnozzle poppet valve acting on
2、a flat flapper seat.The user must supply the flow coefficient characteristic Cq asa function of the pressure ratioPr = downstream pressure (absolute) / upstream pressure (absolute).and of the opening of the valve x (in m).There are two ways to determine this characteristicenter a valid expression fo
3、r Cq in terms of Pr: Cq = f(Pr,x);enter the name of a file in ASCII format.The pressure at port 2 is assumed to act on an active area adjacent to theorifice and tends to open the orifice. A linear pressure gradient (betweenpressure at port 2 and pressure at port 1) acts on the remaining flapperseat
4、area. These assumptions gives a pressure force acting on the flapper.The displacement and velocity of the flapper are supplied by thesubmodel attached to port 3. There are no restriction on thedisplacement within PNAP031 and such restrictions may be applied byanother submodel employing end stops, su
5、ch as PNAI021.The lift is a variable related to this displacement by an offset.The orifice area is never allowed to exceed the area of the throatspecified by the internal diameter of the nozzle and the rod diameter(nozzle side).However, sometimes it is useful to restrict the orifice area withan addi
6、tional minimum and/or maximum value. The minimum areacan be used to simulate a leakage or a special orifice passing floweven when the nozzle is in contact with the flapper. The maximum areacan be used to simulate a flow area, for example at port 2. Theseminimum and maximum areas are specified by the
7、 corresponding liftpositions. The default values imply that there is no additionalrestrictions on the area.Note that the derivative of volume due to the movement of the flapperis sent at port 1 and port 2 to the adjacent pneumatic chamber.-USAGE :Use this submodel for a pneumatic nozzle valve acting
8、 on a flatflapper seat but note that results will be less accurate if the liftexceeds 20% of the seat diameter.PNAP031 differs from PNAP032 only in that the variables associatedwith ports 3 and 4 are interchanged.The submodels PNGD001 or PNGD002 should be included in your circuit todefine the charac
9、teristics of the gas.-PARAMETER SETTINGS :The diameter of the flapper seat must be greater than the internaldiameter of the nozzleThe rod diameter at nozzle side has a default value which is zeroimplying that the rod is not there.The volumes at the ports are normally only significant when the portis
10、 connected to the pneumatic chamber submodels PNCH011 or PNCH012. Ifthis is the case, it is important to set volumes at zero lift sothat the volume outputs are never negative.The filename or expression for Cq = f(Pr,x) is a string like:0.72+0.12*cos(pi*Pr) as an expression or./curves/orif.dat as a f
11、ilenameThe file must provide the data in the following format:N MPr1 Pr2 . PrNx1 x2 . xMCq11 Cq21 . CqN1Cq12 Cq22 . CqN2.Cq1M Cq2M . CqNMwhereN is the number of pressure ratio M is the number of opening positionsPri are the values of the pressure ratio xj are the values of openings mCqij are the val
12、ues of the flow coefficient corresponding to Pri and xj.In this file, data can be separated by any number of space, TAB or RETURN characters.-DATE OF CREATION / AUTHOR:2002 by FS from PNAP31 (SN)-INDEX OF REVISIONS :15/02/2004 : A linear pressure gradient (between pressure at port 2 and pressureat p
13、ort 1) acts on the remaining flapper seat area. (CR)05/01/2012 : Add pressure force contribution when the flapper is at contact (VBD)-LIST OF FUNCTIONS USED :InterpretExpression() : interprets a string as a filenameComputeExpression() : computes the value in the tableaanulsp_() : orifice area of an
14、annular spool valve.pn2rcqfix_() : evaluate mass flow and enthalpy flowpn2getatp_() : get atmospheric pressure-SOURCE :LMS Imagine7, place des Minimes42300 ROANNE tel: (33).04.77.23.60.30FRANCE fax: (33).04.77.23.60.31* */#define _SUBMODELNAME_ PNAP031/* Insert Private Code Here. */* mdr rod diamete
15、r (nozzle side) mm - mdf diameter of the flapper mm - mxlift0 opening (underlap) corresponding to zero displacement mm - mxmin opening for minimum area mm - mxmax opening for maximum area mm - mxlim transition opening for pressure force on the flapper seat mm - mvol10 volume at port 1 corresponding
16、to zero lift cm*3 - m*3vol20 volume at port 2 corresponding to zero lift cm*3 - m*3*/* There are 3 integer parameters:gi gas type indexforcemode pressure acting in the flapper seat areaforcecontact pressure force contribution on the flapper seat at zero lift*/* There is 1 text parameter:flowcoeff fi
17、lename or expression for flow coefficient Cq=f(Pr,x)*/void pnap031in_(int *n, double rp9, int ip3, char *tp1, double c3, int ic3)int loop, error;/* Extra Initialization Function Declarations Here. */static char *var = Pr, x ;/* Initialization Function Check Statements. */if (xmin 0.0)error = 2;amefp
18、rintf(stderr, nLower lift limit must be higher than zero. );if (xmax xmax)error = 2;amefprintf(stderr, nLower lift limit must be smaller than higher lift limit);if (xlim 0);if (di 0);if (df 0);if (df = di)error = 2;amefprintf(stderr, nFlapper seat diameter must be greater);amefprintf(stderr, nthan i
19、nternal diameter of the nozzle);if (dr = 0);if (dr di)error = 2;amefprintf(stderr, nRod diameter (nozzle side) must be lower);amefprintf(stderr, nthan internal diameter of the nozzle);if ( (M_PI*(di*di - dr*dr)/4.0 (M_PI*di*xmax) & (xmax != 1.e30) )if(error != 2)error = 1;amefprintf(stderr, nBe care
20、ful the flow area is limited by );amefprintf(stderr, n(PI/4)*(dinternal2-drod2) and not by PI*dinternal*xmax.n);if (vol10 = 0n);if (vol20 = 0n);/* End of Initialization Check Statements. */* Integer parameter checking: */if (gi 99)amefprintf(stderr, ngas type index must be in range 1.99.n);error = 2
21、;if (forcemode 2)amefprintf(stderr, npressure acting in the flapper seat area must be in range 1.2.n);error = 2;if (forcecontact 2)amefprintf(stderr, npressure force contribution on the flapper seat at zero lift must be in range 1.2.n);error = 2;if(error = 1)amefprintf(stderr, nWarning in %s instanc
22、e %d.n, _SUBMODELNAME_, *n);else if(error = 2)amefprintf(stderr, nFatal error in %s instance %d.n, _SUBMODELNAME_, *n);amefprintf(stderr, Terminating the program.n);AmeExit(1);/* Common - SI units conversions. */rp0 *= 1.00000000000000e-003;di = rp0;rp1 *= 1.00000000000000e-003;dr = rp1;rp2 *= 1.000
23、00000000000e-003;df = rp2;rp3 *= 1.00000000000000e-003;xlift0 = rp3;rp4 *= 1.00000000000000e-003;xmin = rp4;rp5 *= 1.00000000000000e-003;xmax = rp5;rp6 *= 1.00000000000000e-003;xlim = rp6;rp7 *= 1.00000000000000e-006;vol10 = rp7;rp8 *= 1.00000000000000e-006;vol20 = rp8;/* Initialization Function Executable Statements. */ic2 = InterpretExpression(tp0, 2, var,1,1,1,1);if (ic2 = -1)amefprintf(stderr, Invalid expression/filename %sn, tp0);error = 2;/* Calculate the annular area at nozzle side. */c0 = M_PI*(di*di-dr*dr) * 0.25;/* Calculate the remaining annular area on the flapper. */c1 = M_PI*(d
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1