/* Submodel PNL00R skeleton created by AME Submodel editing utility ven. 5. août 14:34:41 2016 */ #include #include #include #include "ameutils.h" /* ******************************************************************************* TITLE : PNL00R ------------------------------------------------------------------------------ DESCRIPTION : PNL00R is a submodel of a pneumatic pipe with only friction effects. Pipe friction is taken into account using a friction factor based on the Reynolds number and the relative roughness. ------------------------------------------------------------------------------ USAGE : Use this submodel to simulate a pneumatic pipe with friction effects, when the Mach number is low, ie gas velocity < 0.3 * speed of sound . The submodels PNGD001 or PNGD002 should be included in your circuit to define the characteristics of the gas. ------------------------------------------------------------------------------ PARAMETER SETTINGS : ------------------------------------------------------------------------------ DATE OF CREATION / AUTHOR : 2002 FS from PNL0R SN ------------------------------------------------------------------------------ REVISIONS : ------------------------------------------------------------------------------ LIST OF FUNCTIONS USED : pn2pipefr_() : frictional coefficient in pneumatic pipes pn2getatp_() : get atmospheric pressure ------------------------------------------------------------------------------ SOURCE : This material contains trade secrets or otherwise confidential information owned by Siemens Industry Software Inc. or its affiliates (collectively, "Siemens"), or its licensors. Access to and use of this information is strictly limited as set forth in the Customer's applicable agreements with Siemens. Unpublished work. Copyright 2023 Siemens ******************************************************************************* */ #define _SUBMODELNAME_ "PNL00R" /* >>>>>>>>>>>>Insert Private Code Here. */ #define TABFR 0 /* real store 0, 1 & 2 are used by pn2pipefr */ #define PATM 3 #define AREA 4 #define SPL_FR 0 /* <<<<<<<<<<< m] le pipe length [m] rr relative roughness [null] */ /* There is 1 integer parameter: gi gas type index */ void pnl00rin_(int *n, double rp[3], int ip[1], double c[5], int ic[1]) { int loop, error; /* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */ /* <<<<<<<<<<<>>>>>>>>>>>Initialization Function Check Statements. */ pn2_valid_gas_(&gi, &error); if (diam <= 0.0) { error = 2; amefprintf(stderr, "\nDiameter of pipe should be > 0 [mm].\n"); } if (le <= 0.0) { error = 2; amefprintf(stderr, "\nPipe length should be > 0 [m].\n"); } if (rr < 0.0) { error = 2; amefprintf(stderr, "\nRelative roughness should be >= 0.\n"); } /* <<<<<<<<<<< 99) { amefprintf(stderr, "\ngas type index must be in range [1..99].\n"); error = 2; } SUBMODEL_HANDLE_AND_RESET_ERROR(_SUBMODELNAME_, n, error) /* Common -> SI units conversions. */ rp[0] *= 1.00000000000000e-003; diam = rp[0]; /* >>>>>>>>>>>>Initialization Function Executable Statements. */ c[PATM] = pn2getatp_(); /* Compute the cross-sectional area of pipe. */ c[AREA] = M_PI * (diam) * (diam) / 4.0; /* <<<<<<<<<<< W] basic variable output 2 dm2 mass flow rate at port 2 [g/s -> kg/s] basic variable output 3 t2 temperature at port 2 [K] basic variable input 4 p2 pressure at port 2 [Pa] basic variable input */ /* There are 4 internal variables. 1 re Reynolds number [null] basic variable 2 cm mass flow parameter (cm) [(kg*K/J)**(1/2)] basic variable 3 v mean gas velocity [m/s] basic variable 4 ff friction factor [null] basic variable */ void pnl00r_(int *n, double *t1, double *p1, double *dh2, double *dm2 , double *t2, double *p2, double *re, double *cm, double *v , double *ff, double rp[3], int ip[1], double c[5], int ic[1]) { int loop; /* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */ double pa1, pa2; double dh1loc, dm1loc; int dummyreg; /* <<<<<<<<<<<>>>>>>>>>>>Calculation Function Executable Statements. */ /* set absolute pressure */ pa1 = *p1 + c[PATM]; pa2 = *p2 + c[PATM]; /* Compute flow through the pipe */ pn2pipefr_(&pa2, t2, &pa1, t1, &diam, &rr, &le, &c[AREA], re, v, ff, dh2, dm2, &dh1loc, &dm1loc, cm, &c[TABFR], &gi, &ic[SPL_FR], &dummyreg); /* <<<<<<<<<<< Common units conversions. */ *dm2 /= 1.00000000000000e-003; }