上传 AMESim 参考资料
This commit is contained in:
1 parent
3f51a124d6
commit
2ddaaeb56a
33 files changed
+6288
No files matched your search
@@ -0,0 +1,224 @@
|
||||
/* Submodel PNL00R skeleton created by AME Submodel editing utility
|
||||
ven. 5. août 14:34:41 2016 */
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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
|
||||
/* <<<<<<<<<<<<End of Private Code. */
|
||||
|
||||
|
||||
/* There are 3 real parameters:
|
||||
|
||||
diam diameter of pipe [mm -> 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. */
|
||||
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
|
||||
int gi;
|
||||
double diam, le, rr;
|
||||
|
||||
gi = ip[0];
|
||||
|
||||
diam = rp[0];
|
||||
le = rp[1];
|
||||
rr = rp[2];
|
||||
loop = 0;
|
||||
error = 0;
|
||||
|
||||
/*
|
||||
If necessary, check values of the following:
|
||||
|
||||
rp[0..2]
|
||||
*/
|
||||
|
||||
|
||||
/* >>>>>>>>>>>>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");
|
||||
}
|
||||
|
||||
/* <<<<<<<<<<<<End of Initialization Check Statements. */
|
||||
|
||||
/* Integer parameter checking: */
|
||||
|
||||
if (gi < 1 || gi > 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;
|
||||
|
||||
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
|
||||
}
|
||||
|
||||
/* There are 2 ports.
|
||||
|
||||
Port 1 has 4 variables:
|
||||
|
||||
1 dh1 duplicate of dh2 (sign reversed)
|
||||
2 dm1 duplicate of dm2 (sign reversed)
|
||||
3 t1 temperature at port 1 [K] basic variable input
|
||||
4 p1 pressure at port 1 [Pa] basic variable input
|
||||
|
||||
Port 2 has 4 variables:
|
||||
|
||||
1 dh2 enthalpy flow rate at port 2 [J/s -> 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;
|
||||
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
|
||||
int gi;
|
||||
double diam, le, rr;
|
||||
|
||||
gi = ip[0];
|
||||
|
||||
diam = rp[0];
|
||||
le = rp[1];
|
||||
rr = rp[2];
|
||||
loop = 0;
|
||||
|
||||
/*
|
||||
Set all submodel outputs below:
|
||||
|
||||
*dh2 = ??;
|
||||
*dm2 = ??;
|
||||
*re = ??;
|
||||
*cm = ??;
|
||||
*v = ??;
|
||||
*ff = ??;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* >>>>>>>>>>>>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);
|
||||
|
||||
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
|
||||
|
||||
/* SI -> Common units conversions. */
|
||||
|
||||
*dm2 /= 1.00000000000000e-003;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user