Poppet valve code in Amesim.docx
《Poppet valve code in Amesim.docx》由会员分享,可在线阅读,更多相关《Poppet valve code in Amesim.docx(15页珍藏版)》请在冰豆网上搜索。
![Poppet valve code in Amesim.docx](https://file1.bdocx.com/fileroot1/2023-1/29/cc4d1d9f-bbd3-43c0-bc90-50d2d4baf847/cc4d1d9f-bbd3-43c0-bc90-50d2d4baf8471.gif)
PoppetvalvecodeinAmesim
/*SubmodelPNAP031skeletoncreatedbyAMESubmodeleditingutility
ven.19.oct.11:
25:
232012*/
#include
#include
#include
#include"ameutils.h"
/********************************************************************************
TITLE:
PNAP031
--------------------------------------------------------------------------------
DESCRIPTION:
PNAP031isasubmodeloftheone-dimensionalmotionofapneumatic
nozzlepoppetvalveactingonaflatflapperseat.
TheusermustsupplytheflowcoefficientcharacteristicCqas
afunctionofthepressureratio
Pr=downstreampressure(absolute)/upstreampressure(absolute).
andoftheopeningofthevalvex(inm).
Therearetwowaystodeterminethischaracteristic
enteravalidexpressionforCqintermsofPr:
Cq=f(Pr,x);
enterthenameofafileinASCIIformat.
Thepressureatport2isassumedtoactonanactiveareaadjacenttothe
orificeandtendstoopentheorifice.Alinearpressuregradient(between
pressureatport2andpressureatport1)actsontheremainingflapper
seatarea.Theseassumptionsgivesapressureforceactingontheflapper.
Thedisplacementandvelocityoftheflapperaresuppliedbythe
submodelattachedtoport3.Therearenorestrictiononthe
displacementwithinPNAP031andsuchrestrictionsmaybeappliedby
anothersubmodelemployingendstops,suchasPNAI021.
Theliftisavariablerelatedtothisdisplacementbyanoffset.
Theorificeareaisneverallowedtoexceedtheareaofthethroat
specifiedbytheinternaldiameterofthenozzleandtheroddiameter
(nozzleside).
However,sometimesitisusefultorestricttheorificeareawith
anadditionalminimumand/ormaximumvalue.Theminimumarea
canbeusedtosimulatealeakageoraspecialorificepassingflow
evenwhenthenozzleisincontactwiththeflapper.Themaximumarea
canbeusedtosimulateaflowarea,forexampleatport2.These
minimumandmaximumareasarespecifiedbythecorrespondinglift
positions.Thedefaultvaluesimplythatthereisnoadditional
restrictionsonthearea.
Notethatthederivativeofvolumeduetothemovementoftheflapper
issentatport1andport2totheadjacentpneumaticchamber.
--------------------------------------------------------------------------------
USAGE:
Usethissubmodelforapneumaticnozzlevalveactingonaflat
flapperseatbutnotethatresultswillbelessaccurateifthelift
exceeds20%oftheseatdiameter.
PNAP031differsfromPNAP032onlyinthatthevariablesassociated
withports3and4areinterchanged.
ThesubmodelsPNGD001orPNGD002shouldbeincludedinyourcircuitto
definethecharacteristicsofthegas.
--------------------------------------------------------------------------------
PARAMETERSETTINGS:
Thediameteroftheflapperseatmustbegreaterthantheinternal
diameterofthenozzle
Theroddiameteratnozzlesidehasadefaultvaluewhichiszero
implyingthattherodisnotthere.
Thevolumesattheportsarenormallyonlysignificantwhentheport
isconnectedtothepneumaticchambersubmodelsPNCH011orPNCH012.If
thisisthecase,itisimportanttosetvolumesatzeroliftso
thatthevolumeoutputsarenevernegative.
ThefilenameorexpressionforCq=f(Pr,x)isastringlike:
0.72+0.12*cos(pi*Pr)asanexpressionor
./curves/orif.datasafilename
Thefilemustprovidethedatainthefollowingformat:
NM
Pr1Pr2...PrN
x1x2...xM
Cq11Cq21...CqN1
Cq12Cq22...CqN2
...
Cq1MCq2M...CqNM
where
NisthenumberofpressureratioMisthenumberofopeningpositions
Priarethevaluesofthepressureratioxjarethevaluesofopenings[m]
CqijarethevaluesoftheflowcoefficientcorrespondingtoPriandxj.
Inthisfile,datacanbeseparatedbyanynumberofspace,TABorRETURNcharacters.
--------------------------------------------------------------------------------
DATEOFCREATION/AUTHOR:
2002byFSfromPNAP31(SN)
--------------------------------------------------------------------------------
INDEXOFREVISIONS:
15/02/2004:
Alinearpressuregradient(betweenpressureatport2andpressure
atport1)actsontheremainingflapperseatarea.(CR)
05/01/2012:
Addpressureforcecontributionwhentheflapperisatcontact(VBD)
--------------------------------------------------------------------------------
LISTOFFUNCTIONSUSED:
InterpretExpression():
interpretsastringasafilename
ComputeExpression():
computesthevalueinthetable
aanulsp_():
orificeareaofanannularspoolvalve.
pn2rcqfix_():
evaluatemassflowandenthalpyflow
pn2getatp_():
getatmosphericpressure
--------------------------------------------------------------------------------
SOURCE:
LMSImagine
7,placedesMinimes
42300ROANNEtel:
(33).04.77.23.60.30
FRANCEfax:
(33).04.77.23.60.31
********************************************************************************/
#define_SUBMODELNAME_"PNAP031"
/*>>>>>>>>>>>>InsertPrivateCodeHere.*/
/*<<<<<<<<<<<
/*Thereare9realparameters:
diinternaldiameterofthenozzle(hole)[mm->m]
drroddiameter(nozzleside)[mm->m]
dfdiameteroftheflapper[mm->m]
xlift0opening(underlap)correspondingtozerodisplacement[mm->m]
xminopeningforminimumarea[mm->m]
xmaxopeningformaximumarea[mm->m]
xlimtransitionopeningforpressureforceontheflapperseat[mm->m]
vol10volumeatport1correspondingtozerolift[cm**3->m**3]
vol20volumeatport2correspondingtozerolift[cm**3->m**3]
*/
/*Thereare3integerparameters:
gigastypeindex
forcemodepressureactingintheflapperseatarea
forcecontactpressureforcecontributionontheflapperseatatzerolift
*/
/*Thereis1textparameter:
flowcoefffilenameorexpressionforflowcoefficientCq=f(Pr,x)
*/
voidpnap031in_(int*n,doublerp[9],intip[3],char*tp[1]
doublec[3],intic[3])
{
intloop,error;
/*>>>>>>>>>>>>ExtraInitializationFunctionDeclarationsHere.*/
staticchar*var[]={"Pr","x"};
/*<<<<<<<<<<<intgi,forcemode,forcecontact;
doubledi,dr,df,xlift0,xmin,xmax,xlim,vol10,vol20;
char*flowcoeff;
gi=ip[0];
forcemode=ip[1];
forcecontact=ip[2];
di=rp[0];
dr=rp[1];
df=rp[2];
xlift0=rp[3];
xmin=rp[4];
xmax=rp[5];
xlim=rp[6];
vol10=rp[7];
vol20=rp[8];
flowcoeff=tp[0];
loop=0;
error=0;
/*
Ifnecessary,checkvaluesofthefollowing:
rp[0..8]
*/
/*>>>>>>>>>>>>InitializationFunctionCheckStatements.*/
if(xmin<0.0)
{
error=2;
amefprintf(stderr,"\nLowerliftlimitmustbehigherthanzero.");
}
if(xmax<=0.0)
{
error=2;
amefprintf(stderr,"\nUpperliftlimitmustbehigherthanzero.");
}
if(xmin>xmax)
{
error=2;
amefprintf(stderr,"\nLowerliftlimitmustbesmallerthanhigherliftlimit");
}
if(xlim<=0.0)
{
error=2;
amefprintf(stderr,"\nTransitionopeningforpressureforceontheflapperseatmustbe>0");
}
if(di<=0.0)
{
error=2;
amefprintf(stderr,"\nInternaldiameterofthenozzlemustbe>0");
}
if(df<=0.0)
{
error=2;
amefprintf(stderr,"\nFlapperseatdiametermustbe>0");
}
if(df<=di)
{
error=2;
amefprintf(stderr,"\nFlapperseatdiametermustbegreater");
amefprintf(stderr,"\nthaninternaldiameterofthenozzle");
}
if(dr<0.0)
{
error=2;
amefprintf(stderr,"\nRoddiameter(nozzleside)mustbe>=0");
}
if(dr>di)
{
error=2;
amefprintf(stderr,"\nRoddiameter(nozzleside)mustbelower");
amefprintf(stderr,"\nthaninternaldiameterofthenozzle");
}
if((M_PI*(di*di-dr*dr)/4.0<(M_PI*di*xmax))&&(xmax!
=1.e30))
{
if(error!
=2)
{
error=1;
}
amefprintf(stderr,"\nBecarefultheflowareaislimitedby");
amefprintf(stderr,"\n(PI/4)*(dinternal^2-drod^2)andnotbyPI*dinternal*xmax.\n");
}
if(vol10<0.0)
{
error=2;
amefprintf(stderr,"\nVolumeatport1correspondingtozeroliftmustbe>=0\n");
}
if(vol20<0.0)
{
error=2;
amefprintf(stderr,"\nVolumeatport2correspondingtozeroliftmustbe>=0\n");
}
/*<<<<<<<<<<</*Integerparameterchecking:
*/
if(gi<1||gi>99)
{
amefprintf(stderr,"\ngastypeindexmustbeinrange[1..99].\n");
error=2;
}
if(forcemode<1||forcemode>2)
{
amefprintf(stderr,"\npressureactingintheflapperseatareamustbeinrange[1..2].\n");
error=2;
}
if(forcecontact<1||forcecontact>2)
{
amefprintf(stderr,"\npressureforcecontributionontheflapperseatatzeroliftmustbeinrange[1..2].\n");
error=2;
}
if(error==1)
{
amefprintf(stderr,"\nWarningin%sinstance%d.\n",_SUBMODELNAME_,*n);
}
elseif(error==2)
{
amefprintf(stderr,"\nFatalerrorin%sinstance%d.\n",_SUBMODELNAME_,*n);
amefprintf(stderr,"Terminatingtheprogram.\n");
AmeExit
(1);
}
/*Common->SIunitsconversions.*/
rp[0]*=1.00000000000000e-003;
di=rp[0];
rp[1]*=1.00000000000000e-003;
dr=rp[1];
rp[2]*=1.00000000000000e-003;
df=rp[2];
rp[3]*=1.00000000000000e-003;
xlift0=rp[3];
rp[4]*=1.00000000000000e-003;
xmin=rp[4];
rp[5]*=1.00000000000000e-003;
xmax=rp[5];
rp[6]*=1.00000000000000e-003;
xlim=rp[6];
rp[7]*=1.00000000000000e-006;
vol10=rp[7];
rp[8]*=1.00000000000000e-006;
vol20=rp[8];
/*>>>>>>>>>>>>InitializationFunctionExecutableStatements.*/
ic[2]=InterpretExpression(tp[0],2,var,1,1,1,1);
if(ic[2]==-1)
{
amefprintf(stderr,"Invalidexpression/filename%s\n",tp[0]);
error=2;
}
/*Calculatetheannularareaatnozzleside.*/
c[0]=M_PI*(di*di-dr*dr)*0.25;
/*Calculatetheremainingannularareaontheflapper.*/
c[1]=M_PI*(d