上传 AMESim 参考资料

This commit is contained in:
huojiarong committed 2026-07-30 10:15:23 +00:00
1 parent 3f51a124d6
commit 2ddaaeb56a
33 files changed
+6288

No files matched your search

+388
View File
@@ -0,0 +1,388 @@
/* Submodel PNCH012 skeleton created by AME Submodel editing utility
mar. oct. 9 14:41:15 2018 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNCH012
--------------------------------------------------------------------------------
DESCRIPTION :
This submodel represents a pneumatic chamber with a variable volume
and pressure dynamics.
Each port receives a mass flow rate and an enthalpy flow rate as
input and gives the pressure and the temperature of the chamber as
output. Each port receives also the volume and volume variation as
input. The total volume is calculated by summing the four volume
inputs and a dead volume which is a parameter of PNCH012.
The model takes into account heat exchange. It express the variation
of internal energy U using the first law of thermodynamics applied to
an open system. Therefore, this model should be preferred to the simple
polytropic chamber PNCH011.
The total volume of the chamber is limited to a lower value equal to
the dead volume divided by 100.
--------------------------------------------------------------------------------
USAGE :
Use this submodel to simulate a pneumatic chamber in a jack, spool
valve or any pneumatic chamber in which the volume can vary.
This submodel can be directly connected to any pneumatic PCD
component or standard pneumatic component.
The submodels PNGD001, PNGD002, PNGD003, PNGD004 or PNRGD00 should be
included in your circuit to define the characteristics of the gas.
--------------------------------------------------------------------------------
PARAMETER SETTINGS:
The dead volume is the volume of the pneumatic fluid when all the input
volumes are zero. It is essential that this volume must be greater
than zero.
--------------------------------------------------------------------------------
DATE OF CREATION / AUTHOR :
2002 FS from PNCH12
--------------------------------------------------------------------------------
INDEX OF REVISIONS :
2008 OBA - Real gas improvements : the mass and volume were considered as
internal state variable, they are now coded as internal basic
variable. The mass initialisation was removed as it was linked
to the perfect gas formulation.
--------------------------------------------------------------------------------
LIST OF FUNCTIONS USED :
pn2getatp : get atmospheric pressure
firstc_ : checks if this is the first call to this submodel
pn2vol_ : pneumatic chamber with heat exchange
stepdn_ : reduce simulation step
--------------------------------------------------------------------------------
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_ "PNCH012"
/* >>>>>>>>>>>>Insert Private Code Here. */
/* <<<<<<<<<<<<End of Private Code. */
/* There are 4 real parameters:
cvol0 dead volume [L -> m**3]
kth thermal exchange coefficient [J/m**2/K/s -> W/m**2/K]
sth thermal exchange area [m**2]
extemp external temperature [K]
*/
/* There is 1 integer parameter:
gi gas type index
*/
void pnch012in_(int *n, double rp[4], int ip[1], double c[2]
, int ic[2], double *temp, double *press, double *dvol1
, double *vol1, double *dvol2, double *vol2, double *dvol3
, double *vol3, double *dvol4, double *vol4)
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi;
double cvol0, kth, sth, extemp;
gi = ip[0];
cvol0 = rp[0];
kth = rp[1];
sth = rp[2];
extemp = rp[3];
loop = 0;
error = 0;
/* Assign default values to input(s) with default. */
*dvol1 = 0.00000000000000e+000;
*vol1 = 0.00000000000000e+000;
*dvol2 = 0.00000000000000e+000;
*vol2 = 0.00000000000000e+000;
*dvol3 = 0.00000000000000e+000;
*vol3 = 0.00000000000000e+000;
*dvol4 = 0.00000000000000e+000;
*vol4 = 0.00000000000000e+000;
/*
If necessary, check values of the following:
rp[0..3]
*temp
*press
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (cvol0 <= 0.0)
{
error = 2;
amefprintf(stderr, "\nVolume chamber must be strictly positive.\n");
}
if (kth < 0.0)
{
error = 2;
amefprintf(stderr, "\nthermal exchange coefficient must be positive.\n");
}
if (sth < 0.0)
{
error = 2;
amefprintf(stderr, "\nthermal exchange area must be positive.\n");
}
if (extemp <= 0.0)
{
error = 2;
amefprintf(stderr, "\nExternal temperature must be strictly positive.\n");
}
if (*temp <= 0.0)
{
error = 2;
amefprintf(stderr, "\nInitial temperature must be strictly positive.\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;
}
if(error == 1)
{
amefprintf(stderr, "\nWarning in %s instance %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. */
rp[0] *= 1.00000000000000e-003;
cvol0 = rp[0];
/* >>>>>>>>>>>>Initialization Function Executable Statements. */
c[0] = cvol0 / 100;
/* Set initial value for the test of limited volume :
ic[1] = 1 when the chamber volume is limited to cvol0 / 100 else ic[1] = 0*/
ic[1] = 0;
/* set atmospheric pressure */
c[1] = pn2getatp_();
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 4 ports.
Port 1 has 6 variables:
1 temp temperature [K] explicit state (derivative `dtemp')
2 press pressure [Pa] explicit state (derivative `dpress')
3 dh1 enthalpy flow rate at port 1 [J/s -> W] basic variable input
4 dm1 mass flow rate at port 1 [g/s -> kg/s] basic variable input
5 dvol1 derivative of volume at port 1 [L/min -> m**3/s] basic variable input with default 0.000000e+000
6 vol1 volume at port 1 [cm**3 -> m**3] basic variable input with default 0.000000e+000
Port 2 has 6 variables:
1 temp2 duplicate of temp
2 press2 duplicate of press
3 dh2 enthalpy flow rate at port 2 [J/s -> W] basic variable input
4 dm2 mass flow rate at port 2 [g/s -> kg/s] basic variable input
5 dvol2 derivative of volume at port 2 [L/min -> m**3/s] basic variable input with default 0.000000e+000
6 vol2 volume at port 2 [cm**3 -> m**3] basic variable input with default 0.000000e+000
Port 3 has 6 variables:
1 temp3 duplicate of temp
2 press3 duplicate of press
3 dh3 enthalpy flow rate at port 3 [J/s -> W] basic variable input
4 dm3 mass flow rate at port 3 [g/s -> kg/s] basic variable input
5 dvol3 derivative of volume at port 3 [L/min -> m**3/s] basic variable input with default 0.000000e+000
6 vol3 volume at port 3 [cm**3 -> m**3] basic variable input with default 0.000000e+000
Port 4 has 6 variables:
1 temp4 duplicate of temp
2 press4 duplicate of press
3 dh4 enthalpy flow rate at port 4 [J/s -> W] basic variable input
4 dm4 mass flow rate at port 4 [g/s -> kg/s] basic variable input
5 dvol4 derivative of volume at port 4 [L/min -> m**3/s] basic variable input with default 0.000000e+000
6 vol4 volume at port 4 [cm**3 -> m**3] basic variable input with default 0.000000e+000
*/
/* There are 2 internal variables.
1 vol volume of pneumatic chamber [cm**3 -> m**3] basic variable
2 mgas1 mass of gas in chamber [g -> kg] basic variable
*/
void pnch012_(int *n, double *temp, double *dtemp, double *press
, double *dpress, double *dh1, double *dm1, double *dvol1
, double *vol1, double *dh2, double *dm2, double *dvol2
, double *vol2, double *dh3, double *dm3, double *dvol3
, double *vol3, double *dh4, double *dm4, double *dvol4
, double *vol4, double *vol, double *mgas1, double rp[4]
, int ip[1], double c[2], int ic[2])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
double dvol;
double sdm, sdh;
double dq;
double pressa;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi;
double cvol0, kth, sth, extemp;
gi = ip[0];
cvol0 = rp[0];
kth = rp[1];
sth = rp[2];
extemp = rp[3];
loop = 0;
/* Common -> SI units conversions. */
*dm1 *= 1.00000000000000e-003;
*dvol1 *= 1.66666666666667e-005;
*vol1 *= 1.00000000000000e-006;
*dm2 *= 1.00000000000000e-003;
*dvol2 *= 1.66666666666667e-005;
*vol2 *= 1.00000000000000e-006;
*dm3 *= 1.00000000000000e-003;
*dvol3 *= 1.66666666666667e-005;
*vol3 *= 1.00000000000000e-006;
*dm4 *= 1.00000000000000e-003;
*dvol4 *= 1.66666666666667e-005;
*vol4 *= 1.00000000000000e-006;
/*
Set all submodel outputs below:
*dtemp = ??;
*dpress = ??;
*vol = ??;
*mgas1 = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressure */
pressa = *press + c[1];
/*** sum of the volume variation and volume ***/
dvol = *dvol1 + *dvol2 + *dvol3 + *dvol4;
/*** setup the initial mass of the gaz inside of the chamber ***/
*vol = *vol1 + *vol2 + *vol3 + *vol4 + cvol0;
/*** sum of the flows ***/
sdm = *dm1 + *dm2 + *dm3 + *dm4; /* mass flow */
sdh = *dh1 + *dh2 + *dh3 + *dh4; /* heat flow */
/*** V, M, T and P can not be lower than zero ***/
*vol = llimit_(vol, &c[0], &ic[0]);
if (ic[0] == -1)
{
dvol = 0.;
if (ic[1] == 0)
{
amefprintf(stderr, "\nWarning in %s instance %d chamber volume is limited by cvol0 / 100 = %g cm**3.\n", _SUBMODELNAME_, *n, c[0]*1E+6);
ic[1] = 1;
}
}
if (*vol < c[0]/10)
{
*vol = c[0]/10;
}
if ( (*mgas1 <= 1.0e-10) && (!firstc_()) )
{
/* panic step reduction */
stepdn_();
*mgas1 = 1.0e-10;
}
if (pressa <= 1.0e-10)
{
/* panic step reduction */
stepdn_();
*press = 1.0e-10 - c[1];
}
if (*temp <= 1.0e-10)
{
/* panic step reduction */
stepdn_();
*temp = 1.0e-10;
}
/*** temperature & pressure variation ***/
dq = kth*sth*(extemp-*temp);
pn2vol_(dtemp, dpress, mgas1, temp, &pressa,
&sdm, &sdh, vol, &dvol, &dq, &gi);
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm1 /= 1.00000000000000e-003;
*dvol1 /= 1.66666666666667e-005;
*vol1 /= 1.00000000000000e-006;
*dm2 /= 1.00000000000000e-003;
*dvol2 /= 1.66666666666667e-005;
*vol2 /= 1.00000000000000e-006;
*dm3 /= 1.00000000000000e-003;
*dvol3 /= 1.66666666666667e-005;
*vol3 /= 1.00000000000000e-006;
*dm4 /= 1.00000000000000e-003;
*dvol4 /= 1.66666666666667e-005;
*vol4 /= 1.00000000000000e-006;
*vol /= 1.00000000000000e-006;
*mgas1 /= 1.00000000000000e-003;
}
+356
View File
@@ -0,0 +1,356 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="16.0.0 - 68387-65635 2017">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>33</SUB_ID_MAX>
<DEFAULT_ICON>pn_c1</DEFAULT_ICON>
<SUB_LABEL>variable volume pneumatic chamber with heat exchange (preferred)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>2</R_STORES_NUMBER>
<I_STORES_NUMBER>2</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>27</SUB_ID>
<TITLE>dead volume</TITLE>
<VARNAME>cvol0</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+00</DEF_VALUE>
<VALUE>1.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+005</MAX_VALUE>
<UNITS>L</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>28</SUB_ID>
<TITLE>thermal exchange coefficient</TITLE>
<VARNAME>kth</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>0.00000000000000e+00</DEF_VALUE>
<VALUE>0.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>J/m**2/K/s</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>29</SUB_ID>
<TITLE>thermal exchange area</TITLE>
<VARNAME>sth</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e-01</DEF_VALUE>
<VALUE>1.00000000000000e-01</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+002</MAX_VALUE>
<UNITS>m**2</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>30</SUB_ID>
<TITLE>external temperature</TITLE>
<VARNAME>extemp</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>2.93150000000000e+02</DEF_VALUE>
<VALUE>2.93150000000000e+02</VALUE>
<MIN_VALUE>1.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+003</MAX_VALUE>
<UNITS>K</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>31</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>32</SUB_ID>
<TITLE>volume of pneumatic chamber</TITLE>
<VARNAME>vol</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>cm**3</UNITS>
</IVAR>
<IVAR>
<SUB_ID>33</SUB_ID>
<TITLE>mass of gas in chamber</TITLE>
<VARNAME>mgas1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>g</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>temperature</TITLE>
<VARNAME>temp</VARNAME>
<VARNAME2>dtemp</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>K</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+003</MAX_VALUE>
<DEF_VALUE>2.93150000000000e+002</DEF_VALUE>
<VALUE>2.93150000000000e+002</VALUE>
</EVAR>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>pressure</TITLE>
<VARNAME>press</VARNAME>
<VARNAME2>dpress</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>Pa</UNITS>
<MIN_VALUE>-1.01300000000000e+005</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+012</MAX_VALUE>
<DEF_VALUE>0.00000000000000e+000</DEF_VALUE>
<VALUE>0.00000000000000e+000</VALUE>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>enthalpy flow rate at port 1</TITLE>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>mass flow rate at port 1</TITLE>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>derivative of volume at port 1</TITLE>
<VARNAME>dvol1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>L/min</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<TITLE>volume at port 1</TITLE>
<VARNAME>vol1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>cm**3</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>7</SUB_ID>
<VARNAME>temp2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<VARNAME>press2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>9</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>10</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>11</SUB_ID>
<TITLE>derivative of volume at port 2</TITLE>
<VARNAME>dvol2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>L/min</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
<EVAR>
<SUB_ID>12</SUB_ID>
<TITLE>volume at port 2</TITLE>
<VARNAME>vol2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>cm**3</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>13</SUB_ID>
<VARNAME>temp3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>14</SUB_ID>
<VARNAME>press3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>15</SUB_ID>
<TITLE>enthalpy flow rate at port 3</TITLE>
<VARNAME>dh3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>16</SUB_ID>
<TITLE>mass flow rate at port 3</TITLE>
<VARNAME>dm3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>17</SUB_ID>
<TITLE>derivative of volume at port 3</TITLE>
<VARNAME>dvol3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>L/min</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
<EVAR>
<SUB_ID>18</SUB_ID>
<TITLE>volume at port 3</TITLE>
<VARNAME>vol3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>cm**3</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>19</SUB_ID>
<VARNAME>temp4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>20</SUB_ID>
<VARNAME>press4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>0</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>21</SUB_ID>
<TITLE>enthalpy flow rate at port 4</TITLE>
<VARNAME>dh4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>22</SUB_ID>
<TITLE>mass flow rate at port 4</TITLE>
<VARNAME>dm4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>23</SUB_ID>
<TITLE>derivative of volume at port 4</TITLE>
<VARNAME>dvol4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>L/min</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
<EVAR>
<SUB_ID>24</SUB_ID>
<TITLE>volume at port 4</TITLE>
<VARNAME>vol4</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>3</IO>
<UNITS>cm**3</UNITS>
<DEF_VALUE>0</DEF_VALUE>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+348
View File
@@ -0,0 +1,348 @@
/* Submodel PNL0001 skeleton created by AME Submodel editing utility
mer. juin 20 14:20:39 2018 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNL0001 (C-R)
------------------------------------------------------------------------------
DESCRIPTION :
PNL0001 is a submodel of a pneumatic pipe with only compressibility
and friction effects taking into account heat exchange.
The compressibility of the gas is taken into account by using a
simple polytropic model or a more complex one taking into account
heat exchange.
The polytropic model is a simplified form of the general internal
energy model based on the first law of thermodynamics. The polytropic
approach is obtained by representing the thermal exchange phenomena
by a polytropic constant k. In that case, the temperature and
pressure are no more independent variables.
The reduction of the complexity of the model implies a lack of
accuracy. For general studies, you'd better use the heat exchange
approach.
Pipe friction is taken into account using a friction factor based on
the Reynolds number and the relative roughness.
The temperature and pressure in the volume are state variables.
------------------------------------------------------------------------------
USAGE :
Use this submodel to simulate a pneumatic pipe with compressibility
and 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 PNL01 SN.
------------------------------------------------------------------------------
REVISIONS :
------------------------------------------------------------------------------
LIST OF FUNCTIONS USED :
pn2getatp_() : get atmospheric pressure
pn2ri_() : get perfect gas constant
pn2vol1_() : polytropic model for chambers
pn2vol_() : heat exchange model for chambers
pn2pipefr_() : frictional coeffitient in pneumatic pipes
------------------------------------------------------------------------------
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_ "PNL0001"
/* >>>>>>>>>>>>Insert Private Code Here. */
#define TABFR 0 /* real store 0, 1 & 2 are used by pn2pipefr */
#define PATM 3
#define AREA 4
#define VOL 5
#define AREAEX 6
#define SPL_FR 0
/* <<<<<<<<<<<<End of Private Code. */
/* There are 6 real parameters:
diam diameter of pipe [mm -> m]
le pipe length [m]
rr relative roughness [null]
k polytropic constant [null]
kth thermal exchange coefficient [J/m**2/K/s -> W/m**2/K]
extemp external temperature [K]
*/
/* There are 2 integer parameters:
gi gas type index
mode model
*/
void pnl0001in_(int *n, double rp[6], int ip[2], double c[7]
, int ic[1], double *t2, double *p2)
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
error = 0;
/*
If necessary, check values of the following:
rp[0..5]
*t2
*p2
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (*p2 < -GPATMOS)
{
error = 2;
amefprintf(stderr, "\nInitial pressure at port 2 should be > 0 [barA].\n");
}
if (*t2 <= 0.0)
{
error = 2;
amefprintf(stderr, "\nInitial temperature at port 2 should be > 0 [K].\n");
}
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");
}
if (mode == 1)
{
if (k <= 0.)
{
error = 2;
amefprintf(stderr, "\nPolytropic constant should be > 0.\n");
}
}
else
{
if (kth < 0.)
{
error = 2;
amefprintf(stderr, "\nThermal exchange coefficient should be >= 0 [J/m**2/K/s].\n");
}
if (extemp <= 0.)
{
error = 2;
amefprintf(stderr, "\nExternal temperature should be > 0 [K].\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;
}
if (mode < 1 || mode > 2)
{
amefprintf(stderr, "\nmodel must be in range [1..2].\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. */
/* get atmospheric pressure */
c[PATM] = pn2getatp_();
/* Compute the cross-sectional area of pipe. */
c[AREA] = M_PI * (diam) * (diam) / 4.0;
/* Compute volume of pipe. */
c[VOL] = c[AREA] * le;
/* Compute exchange area of pipe. */
c[AREAEX] = M_PI * diam * le;
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 2 ports.
Port 1 has 4 variables:
1 dh1 enthalpy flow rate at port 1 [J/s -> W] basic variable output
2 dm1 mass flow rate at port 1 [g/s -> kg/s] basic variable output
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 t2 temperature at port 2 [K] explicit state (derivative `dt2')
2 p2 pressure at port 2 [Pa] explicit state (derivative `dp2')
3 dh2 enthalpy flow rate at port 2 [J/s -> W] basic variable input
4 dm2 mass flow rate at port 2 [g/s -> kg/s] basic variable input
*/
/* There are 5 internal variables.
1 mgas mass of gas in pipe [g -> kg] basic variable
2 re Reynolds number [null] basic variable
3 cm mass flow parameter (cm) [(kg*K/J)**(1/2)] basic variable
4 v mean gas velocity [m/s] basic variable
5 ff friction factor [null] basic variable
*/
void pnl0001_(int *n, double *dh1, double *dm1, double *t1, double *p1
, double *t2, double *dt2, double *p2, double *dp2, double *dh2
, double *dm2, double *mgas, double *re, double *cm, double *v
, double *ff, double rp[6], int ip[2], double c[7], int ic[1])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
static double zero = 0.0;
double sdh;
double dh2i, dm2i;
double dq;
double pa1, pa2, dmgas;
double r;
int dummyreg;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
/* Common -> SI units conversions. */
*dm2 *= 1.00000000000000e-003;
/*
Set all submodel outputs below:
*dh1 = ??;
*dm1 = ??;
*dt2 = ??;
*dp2 = ??;
*mgas = ??;
*re = ??;
*cm = ??;
*v = ??;
*ff = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressures */
pa1 = *p1 + c[PATM];
pa2 = *p2 + c[PATM];
/* Compute flows through the pipe */
pn2pipefr_(&pa1, t1, &pa2, t2, &diam, &rr, &le, &c[AREA], re, v,ff,
dh1, dm1, &dh2i, &dm2i, cm, &c[TABFR], &gi, &ic[SPL_FR], &dummyreg);
/* Compute mass variation */
dmgas = (*dm2) + dm2i;
/* sum of enthalpy flows */
sdh = (*dh2) + dh2i;
/*** temperature & pressure variation ***/
if (mode == 1) /* Polytropic model. */
{
r = pn2ri_(&gi);
/* Compute initial mass of gas inside the pipe */
*mgas = (pa2) * c[VOL] / ((*t2) * r);
pn2vol1_(dt2, dp2, t2, &pa2,
&dmgas, mgas, &zero, &c[VOL], &k, &gi);
}
else /* Heat exchange. */
{
dq = kth * c[AREAEX] * (extemp - *t2);
pn2vol_(dt2, dp2, mgas, t2, &pa2,
&dmgas, &sdh, &c[VOL], &zero, &dq, &gi);
}
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm1 /= 1.00000000000000e-003;
*dm2 /= 1.00000000000000e-003;
*mgas /= 1.00000000000000e-003;
}
+257
View File
@@ -0,0 +1,257 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="16.0.0 - 68387-65635 2017">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>22</SUB_ID_MAX>
<DEFAULT_ICON>p2port</DEFAULT_ICON>
<SUB_LABEL>Compressibility + friction submodel of pneumatic pipe (C-R)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>7</R_STORES_NUMBER>
<I_STORES_NUMBER>1</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>14</SUB_ID>
<TITLE>diameter of pipe</TITLE>
<VARNAME>diam</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+01</DEF_VALUE>
<VALUE>1.00000000000000e+01</VALUE>
<MIN_VALUE>1.00000000000000e-003</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+007</MAX_VALUE>
<UNITS>mm</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>15</SUB_ID>
<TITLE>pipe length</TITLE>
<VARNAME>le</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+00</DEF_VALUE>
<VALUE>1.00000000000000e+00</VALUE>
<MIN_VALUE>1.00000000000000e-006</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<UNITS>m</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>16</SUB_ID>
<TITLE>relative roughness</TITLE>
<VARNAME>rr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e-05</DEF_VALUE>
<VALUE>1.00000000000000e-05</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e-001</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>17</SUB_ID>
<TITLE>polytropic constant</TITLE>
<VARNAME>k</VARNAME>
<VISIBILITY>(mode == 1)</VISIBILITY>
<DEF_VALUE>1.35000000000000e+00</DEF_VALUE>
<VALUE>1.35000000000000e+00</VALUE>
<MIN_VALUE>5.00000000000000e-001</MIN_VALUE>
<MAX_VALUE>2.00000000000000e+000</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>18</SUB_ID>
<TITLE>thermal exchange coefficient</TITLE>
<VARNAME>kth</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>0.00000000000000e+00</DEF_VALUE>
<VALUE>0.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>J/m**2/K/s</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>19</SUB_ID>
<TITLE>external temperature</TITLE>
<VARNAME>extemp</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>2.93150000000000e+02</DEF_VALUE>
<VALUE>2.93150000000000e+02</VALUE>
<MIN_VALUE>1.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+003</MAX_VALUE>
<UNITS>K</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>20</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
<IPARAM>
<SUB_ID>21</SUB_ID>
<TITLE>model</TITLE>
<VARNAME>mode</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>2</DEF_VALUE>
<VALUE>2</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>2</MAX_VALUE>
<ENUM_LIST>
<ENUM>
<ENUM_STRING>polytropic</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>with thermal exchange</ENUM_STRING>
</ENUM>
</ENUM_LIST>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>22</SUB_ID>
<TITLE>mass of gas in pipe</TITLE>
<VARNAME>mgas</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>g</UNITS>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>Reynolds number</TITLE>
<VARNAME>re</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
<IVAR>
<SUB_ID>11</SUB_ID>
<TITLE>mass flow parameter (cm)</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>12</SUB_ID>
<TITLE>mean gas velocity</TITLE>
<VARNAME>v</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>13</SUB_ID>
<TITLE>friction factor</TITLE>
<VARNAME>ff</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>enthalpy flow rate at port 1</TITLE>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>mass flow rate at port 1</TITLE>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>temperature at port 1</TITLE>
<VARNAME>t1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>pressure at port 1</TITLE>
<VARNAME>p1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>t2</VARNAME>
<VARNAME2>dt2</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>K</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<DEF_VALUE>2.93150000000000e+002</DEF_VALUE>
<VALUE>2.93150000000000e+002</VALUE>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>p2</VARNAME>
<VARNAME2>dp2</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>Pa</UNITS>
<MIN_VALUE>-1.01300000000000e+005</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+012</MAX_VALUE>
<DEF_VALUE>0.00000000000000e+000</DEF_VALUE>
<VALUE>0.00000000000000e+000</VALUE>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+368
View File
@@ -0,0 +1,368 @@
/* Submodel PNL0002 skeleton created by AME Submodel editing utility
mer. juin 20 14:35:13 2018 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNL0002 (R-C-R)
------------------------------------------------------------------------------
DESCRIPTION :
PNL0002 is a submodel of a pneumatic pipe with only compressibility
and friction effects taking into account heat exchange.
The compressibility of the gas is taken into account by using a
simple polytropic model or a more complex one taking into account
heat exchange.
The polytropic model is a simplified form of the general internal
energy model based on the first law of thermodynamics. The polytropic
approach is obtained by representing the thermal exchange phenomena
by a polytropic constant k. In that case, the temperature and
pressure are no more independent variables.
The reduction of the complexity of the model implies a lack of
accuracy. For general studies, you'd better use the heat exchange
approach.
Pipe friction is taken into account using a friction factor based on
the Reynolds number and the relative roughness.
The temperature and pressure in the middle volume are state variables.
------------------------------------------------------------------------------
USAGE :
Use this submodel to simulate a pneumatic pipe with compressibility
and friction effects, when the Mach number is low, ie gas velocity
< 0.3 * speed of sound .
PNL0002 is basically similar to PNL0001 and PNL0003 differing only in the
input and output requirements.
The submodels PNGD01 or PNGD02 should be included in your circuit to
define the characteristics of the gas.
------------------------------------------------------------------------------
PARAMETER SETTINGS :
------------------------------------------------------------------------------
DATE OF CREATION / AUTHOR :
2002 FS from PNL02 SN.
------------------------------------------------------------------------------
REVISIONS :
------------------------------------------------------------------------------
LIST OF FUNCTIONS USED :
pn2getatp_() : get atmospheric pressure
pn2ri_() : get perfect gas constant
pn2vol1_() : polytropic model for chambers
pn2vol_() : heat exchange model for chambers
pn2pipefr_() : frictional coeffitient in pneumatic pipes
------------------------------------------------------------------------------
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_ "PNL0002"
/* >>>>>>>>>>>>Insert Private Code Here. */
#define TABFR 0 /* real store 0, 1 & 2 are used by pn2pipefr */
#define PATM 3
#define AREA 4
#define VOL 5
#define HALFLE 6
#define AREAEX 7
#define SPL_FR 0
/* <<<<<<<<<<<<End of Private Code. */
/* There are 6 real parameters:
diam diameter of pipe [mm -> m]
le pipe length [m]
rr relative roughness [null]
k polytropic constant [null]
kth thermal exchange coefficient [J/m**2/K/s -> W/m**2/K]
extemp external temperature [K]
*/
/* There are 2 integer parameters:
gi gas type index
mode model
*/
void pnl0002in_(int *n, double rp[6], int ip[2], double c[8]
, int ic[1], double *tctr, double *pctr)
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
error = 0;
/*
If necessary, check values of the following:
rp[0..5]
*tctr
*pctr
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (*pctr < -GPATMOS)
{
error = 2;
amefprintf(stderr, "\nInitial pressure at center of pipe should be > 0 [barA].\n");
}
if (*tctr <= 0.0)
{
error = 2;
amefprintf(stderr, "\nInitial temperature at center of pipe should be > 0 [K].\n");
}
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");
}
if (mode == 1)
{
if (k <= 0.)
{
error = 2;
amefprintf(stderr, "\nPolytropic constant should be > 0.\n");
}
}
else
{
if (kth < 0.)
{
error = 2;
amefprintf(stderr, "\nThermal exchange coefficient should be >= 0 [J/m**2/K/s].\n");
}
if (extemp <= 0.)
{
error = 2;
amefprintf(stderr, "\nExternal temperature should be > 0 [K].\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;
}
if (mode < 1 || mode > 2)
{
amefprintf(stderr, "\nmodel must be in range [1..2].\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. */
/* get atmospheric pressure */
c[PATM] = pn2getatp_();
/* Compute the cross-sectional area of pipe. */
c[AREA] = M_PI * (diam) * (diam) / 4.0;
/* Compute volume of pipe. */
c[VOL] = c[AREA] * le;
/* Divide the restriction in 2 identical restrictions */
c[HALFLE] = 0.5 * le;
/* Compute exchange area of pipe. */
c[AREAEX] = M_PI * diam * le;
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 2 ports.
Port 1 has 4 variables:
1 dh1 enthalpy flow rate at port 1 [J/s -> W] basic variable output
2 dm1 mass flow rate at port 1 [g/s -> kg/s] basic variable output
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 7 internal variables.
1 tctr temperature at center of pipe [K] explicit state (derivative `dtctr')
2 pctr pressure at center of pipe [Pa] explicit state (derivative `dpctr')
3 mgas mass of gas in pipe [g -> kg] basic variable
4 re mean Reynolds number [null] basic variable
5 cm mean mass flow parameter [(kg*K/J)**(1/2)] basic variable
6 v mean gas velocity [m/s] basic variable
7 ff mean friction factor [null] basic variable
*/
void pnl0002_(int *n, double *dh1, double *dm1, double *t1, double *p1
, double *dh2, double *dm2, double *t2, double *p2, double *tctr
, double *dtctr, double *pctr, double *dpctr, double *mgas
, double *re, double *cm, double *v, double *ff, double rp[6]
, int ip[2], double c[8], int ic[1])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
static double zero = 0.0;
double sdh;
double dh1i, dm1i;
double dh2i, dm2i;
double ff1, ff2, re1, re2, cm1, cm2;
double dq;
double pa1, pa2, pactr;
double v1, v2;
double dmgas;
double r;
int dummyreg;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
/*
Set all submodel outputs below:
*dh1 = ??;
*dm1 = ??;
*dh2 = ??;
*dm2 = ??;
*dtctr = ??;
*dpctr = ??;
*mgas = ??;
*re = ??;
*cm = ??;
*v = ??;
*ff = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressure */
pa1 = *p1 + c[PATM];
pa2 = *p2 + c[PATM];
pactr = *pctr + c[PATM];
/* Compute flows through the pipe */
pn2pipefr_(&pa1, t1, &pactr, tctr, &diam, &rr, &c[HALFLE], &c[AREA], &re1, &v1, &ff1,
dh1, dm1, &dh1i, &dm1i, &cm1, &c[TABFR], &gi, &ic[SPL_FR], &dummyreg);
pn2pipefr_(&pactr, tctr, &pa2, t2, &diam, &rr, &c[HALFLE], &c[AREA], &re2, &v2, &ff2,
&dh2i, &dm2i, dh2, dm2, &cm2, &c[TABFR], &gi, &ic[SPL_FR], &dummyreg);
/* Mean variables */
*ff = 0.5 * (ff1 + ff2);
*re = 0.5 * (re1 + re2);
*cm = 0.5 * (cm1 + cm2);
*v = 0.5 * (fabs(v1) + fabs(v2));
/* Compute mass variation */
dmgas = dm1i + dm2i;
/* sum of enthalpy flows */
sdh = dh1i + dh2i;
/*** temperature & pressure variation ***/
if (mode == 1) /* Polytropic model. */
{
r = pn2ri_(&gi);
*mgas = (pactr) * c[VOL] / ((*tctr) * r);
pn2vol1_(dtctr, dpctr, tctr, &pactr,
&dmgas, mgas, &zero, &c[VOL], &k, &gi);
}
else /* Heat exchange. */
{
dq = kth * c[AREAEX] * (extemp-*tctr);
pn2vol_(dtctr, dpctr, mgas, tctr, &pactr,
&dmgas, &sdh, &c[VOL], &zero, &dq, &gi);
}
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm1 /= 1.00000000000000e-003;
*dm2 /= 1.00000000000000e-003;
*mgas /= 1.00000000000000e-003;
}
+275
View File
@@ -0,0 +1,275 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="16.0.0 - 68387-65635 2017">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>24</SUB_ID_MAX>
<DEFAULT_ICON>p2port</DEFAULT_ICON>
<SUB_LABEL>Compressibility + friction submodel of pneumatic pipe (R-C-R)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>8</R_STORES_NUMBER>
<I_STORES_NUMBER>1</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>16</SUB_ID>
<TITLE>diameter of pipe</TITLE>
<VARNAME>diam</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+01</DEF_VALUE>
<VALUE>1.00000000000000e+01</VALUE>
<MIN_VALUE>1.00000000000000e-003</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+007</MAX_VALUE>
<UNITS>mm</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>17</SUB_ID>
<TITLE>pipe length</TITLE>
<VARNAME>le</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+00</DEF_VALUE>
<VALUE>1.00000000000000e+00</VALUE>
<MIN_VALUE>1.00000000000000e-006</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<UNITS>m</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>18</SUB_ID>
<TITLE>relative roughness</TITLE>
<VARNAME>rr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e-05</DEF_VALUE>
<VALUE>1.00000000000000e-05</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e-001</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>19</SUB_ID>
<TITLE>polytropic constant</TITLE>
<VARNAME>k</VARNAME>
<VISIBILITY>(mode == 1)</VISIBILITY>
<DEF_VALUE>1.35000000000000e+00</DEF_VALUE>
<VALUE>1.35000000000000e+00</VALUE>
<MIN_VALUE>5.00000000000000e-001</MIN_VALUE>
<MAX_VALUE>2.00000000000000e+000</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>20</SUB_ID>
<TITLE>thermal exchange coefficient</TITLE>
<VARNAME>kth</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>0.00000000000000e+00</DEF_VALUE>
<VALUE>0.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>J/m**2/K/s</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>21</SUB_ID>
<TITLE>external temperature</TITLE>
<VARNAME>extemp</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>2.93150000000000e+02</DEF_VALUE>
<VALUE>2.93150000000000e+02</VALUE>
<MIN_VALUE>1.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+003</MAX_VALUE>
<UNITS>K</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>22</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
<IPARAM>
<SUB_ID>23</SUB_ID>
<TITLE>model</TITLE>
<VARNAME>mode</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>2</DEF_VALUE>
<VALUE>2</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>2</MAX_VALUE>
<ENUM_LIST>
<ENUM>
<ENUM_STRING>polytropic</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>with thermal exchange</ENUM_STRING>
</ENUM>
</ENUM_LIST>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>9</SUB_ID>
<TITLE>temperature at center of pipe</TITLE>
<VARNAME>tctr</VARNAME>
<VARNAME2>dtctr</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>K</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<DEF_VALUE>2.931500e+02</DEF_VALUE>
<VALUE>2.931500e+02</VALUE>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>pressure at center of pipe</TITLE>
<VARNAME>pctr</VARNAME>
<VARNAME2>dpctr</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>Pa</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<DEF_VALUE>1.013000e+00</DEF_VALUE>
<VALUE>1.013000e+00</VALUE>
</IVAR>
<IVAR>
<SUB_ID>24</SUB_ID>
<TITLE>mass of gas in pipe</TITLE>
<VARNAME>mgas</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>g</UNITS>
</IVAR>
<IVAR>
<SUB_ID>12</SUB_ID>
<TITLE>mean Reynolds number</TITLE>
<VARNAME>re</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
<IVAR>
<SUB_ID>13</SUB_ID>
<TITLE>mean mass flow parameter</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>14</SUB_ID>
<TITLE>mean gas velocity</TITLE>
<VARNAME>v</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>15</SUB_ID>
<TITLE>mean friction factor</TITLE>
<VARNAME>ff</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>enthalpy flow rate at port 1</TITLE>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>mass flow rate at port 1</TITLE>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>temperature at port 1</TITLE>
<VARNAME>t1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>pressure at port 1</TITLE>
<VARNAME>p1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>t2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>p2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+399
View File
@@ -0,0 +1,399 @@
/* Submodel PNL0003 skeleton created by AME Submodel editing utility
mer. juin 20 14:17:28 2018 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNL0003 (C-R-C)
------------------------------------------------------------------------------
DESCRIPTION :
PNL0003 is a submodel of a pneumatic pipe with only compressibility
and friction effects taking into account heat exchange.
The compressibility of the gas is taken into account by using a
simple polytropic model or a more complex one taking into account
heat exchange.
The polytropic model is a simplified form of the general internal
energy model based on the first law of thermodynamics. The polytropic
approach is obtained by representing the thermal exchange phenomena
by a polytropic constant k. In that case, the temperature and
pressure are no more independent variables.
The reduction of the complexity of the model implies a lack of
accuracy. For general studies, you'd better use the heat exchange
approach.
Pipe friction is taken into account using a friction factor based on
the Reynolds number and the relative roughness.
The temperature and pressure in each two volumes are state variables.
------------------------------------------------------------------------------
USAGE :
Use this submodel to simulate a pneumatic pipe with compressibility
and friction effects, when the Mach number is low, ie gas velocity
< 0.3 * speed of sound .
PNL0003 is basically similar to PNL0001 and PNL0002 differing only in the
input and output requirements.
The submodels PNGD01 or PNGD02 should be included in your circuit to
define the characteristics of the gas.
------------------------------------------------------------------------------
PARAMETER SETTINGS :
------------------------------------------------------------------------------
DATE OF CREATION / AUTHOR :
2002 FS from PNL03 SN.
------------------------------------------------------------------------------
REVISIONS :
------------------------------------------------------------------------------
LIST OF FUNCTIONS USED :
pn2getatp_() : get atmospheric pressure
pn2ri_() : get perfect gas constant
pn2vol1_() : polytropic model for chambers
pn2vol_() : heat exchange model for chambers
pn2pipefr_() : frictional coefficient in pneumatic pipes
------------------------------------------------------------------------------
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_ "PNL0003"
/* >>>>>>>>>>>>Insert Private Code Here. */
#define TABFR 0 /* real store 0, 1 & 2 are used by pn2pipefr */
#define PATM 3
#define AREA 4
#define HALFVOL 5
#define HALFAREAEX 6
#define SPL_FR 0
/* <<<<<<<<<<<<End of Private Code. */
/* There are 6 real parameters:
diam diameter of pipe [mm -> m]
le pipe length [m]
rr relative roughness [null]
k polytropic constant [null]
kth thermal exchange coefficient [J/m**2/K/s -> W/m**2/K]
extemp external temperature [K]
*/
/* There are 2 integer parameters:
gi gas type index
mode model
*/
void pnl0003in_(int *n, double rp[6], int ip[2], double c[7]
, int ic[1], double *t1, double *p1, double *t2, double *p2)
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
double vol, areaex;
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
error = 0;
/*
If necessary, check values of the following:
rp[0..5]
*t1
*p1
*t2
*p2
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (*p1 < -GPATMOS)
{
error = 2;
amefprintf(stderr, "\nInitial pressure at port 1 should be > 0 [barA].\n");
}
if (*t1 <= 0.0)
{
error = 2;
amefprintf(stderr, "\nInitial temperature at port 1 should be > 0 [K].\n");
}
if (*p2 < -GPATMOS)
{
error = 2;
amefprintf(stderr, "\nInitial pressure at port 2 should be > 0 [barA].\n");
}
if (*t2 <= 0.0)
{
error = 2;
amefprintf(stderr, "\nInitial temperature at port 2 should be > 0 [K].\n");
}
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");
}
if (mode == 1)
{
if (k <= 0.)
{
error = 2;
amefprintf(stderr, "\nPolytropic constant should be > 0.\n");
}
}
else
{
if (kth < 0.)
{
error = 2;
amefprintf(stderr, "\nThermal exchange coefficient should be >= 0 [J/m**2/K/s].\n");
}
if (extemp <= 0.)
{
error = 2;
amefprintf(stderr, "\nExternal temperature should be > 0 [K].\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;
}
if (mode < 1 || mode > 2)
{
amefprintf(stderr, "\nmodel must be in range [1..2].\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. */
/* set atmospheric pressure */
c[PATM] = pn2getatp_();
/* Compute the cross-sectional area of pipe. */
c[AREA] = M_PI * (diam) * (diam) / 4.0;
/* Compute volume of pipe. */
vol = c[AREA] * le;
/* Divide the volume in 2 identical volumes */
c[HALFVOL] = 0.5 * vol;
/* Compute exchange area of pipe. */
areaex = M_PI * diam * le;
/* Divide the exchange area of pipe in 2 identical areas */
c[HALFAREAEX] = 0.5 * areaex;
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 2 ports.
Port 1 has 4 variables:
1 t1 temperature at port 1 [K] explicit state (derivative `dt1')
2 p1 pressure at port 1 [Pa] explicit state (derivative `dp1')
3 dh1 enthalpy flow rate at port 1 [J/s -> W] basic variable input
4 dm1 mass flow rate at port 1 [g/s -> kg/s] basic variable input
Port 2 has 4 variables:
1 t2 temperature at port 2 [K] explicit state (derivative `dt2')
2 p2 pressure at port 2 [Pa] explicit state (derivative `dp2')
3 dh2 enthalpy flow rate at port 2 [J/s -> W] basic variable input
4 dm2 mass flow rate at port 2 [g/s -> kg/s] basic variable input
*/
/* There are 7 internal variables.
1 dhctr enthalpy flow at center of pipe [J/s -> W] basic variable
2 dmctr mass flow at center of pipe [g/s -> kg/s] basic variable
3 mgas mass of gas in pipe [g -> kg] basic variable
4 re Reynolds number [null] basic variable
5 cm mass flow parameter (cm) [(kg*K/J)**(1/2)] basic variable
6 v mean gas velocity [m/s] basic variable
7 ff friction factor [null] basic variable
*/
void pnl0003_(int *n, double *t1, double *dt1, double *p1, double *dp1
, double *dh1, double *dm1, double *t2, double *dt2, double *p2
, double *dp2, double *dh2, double *dm2, double *dhctr
, double *dmctr, double *mgas, double *re, double *cm, double *v
, double *ff, double rp[6], int ip[2], double c[7], int ic[1])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
static double zero = 0.0;
double dh1i, dm1i;
double dh2i, dm2i;
double sdh1, sdm1;
double sdh2, sdm2;
double m1, m2;
double dq1, dq2;
double pa1, pa2;
double dmgas;
double r;
int dummyreg;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi, mode;
double diam, le, rr, k, kth, extemp;
gi = ip[0];
mode = ip[1];
diam = rp[0];
le = rp[1];
rr = rp[2];
k = rp[3];
kth = rp[4];
extemp = rp[5];
loop = 0;
/* Common -> SI units conversions. */
*dm1 *= 1.00000000000000e-003;
*dm2 *= 1.00000000000000e-003;
/*
Set all submodel outputs below:
*dt1 = ??;
*dp1 = ??;
*dt2 = ??;
*dp2 = ??;
*dhctr = ??;
*dmctr = ??;
*mgas = ??;
*re = ??;
*cm = ??;
*v = ??;
*ff = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressures */
pa1 = *p1 + c[PATM];
pa2 = *p2 + c[PATM];
/* Compute flow through the pipe */
pn2pipefr_(&pa1, t1, &pa2, t2, &diam, &rr, &le, &c[AREA], re, v, ff,
&dh1i, &dm1i, &dh2i, &dm2i, cm, &c[TABFR], &gi, &ic[SPL_FR], &dummyreg);
/* Enthalpy flow and mass flow at center of pipe */
*dhctr = dh1i; /* = -dh2i */
*dmctr = dm1i; /* = -dm2i */
/* Compute the sum of the flows inside each volume */
sdm1 = *dm1 + dm1i;
sdh1 = *dh1 + dh1i;
sdm2 = *dm2 + dm2i;
sdh2 = *dh2 + dh2i;
dmgas = sdm1 + sdm2;
/*** temperature & pressure variation ***/
if (mode == 1) /* Polytropic model. */
{
r = pn2ri_(&gi);
/* Current mass in each volume */
m1 = pa1 * c[HALFVOL] / (*t1 * r);
m2 = pa2 * c[HALFVOL] / (*t2 * r);
pn2vol1_(dt1, dp1, t1, &pa1,
&sdm1, &m1, &zero, &c[HALFVOL], &k,&gi);
pn2vol1_(dt2, dp2, t2, &pa2,
&sdm2, &m2, &zero, &c[HALFVOL], &k,&gi);
}
else /* Heat exchange. */
{
dq1 = kth * c[HALFAREAEX] * (extemp - *t1);
pn2vol_(dt1, dp1, &m1, t1, &pa1,
&sdm1, &sdh1, &c[HALFVOL], &zero, &dq1, &gi);
dq2 = kth * c[HALFAREAEX] * (extemp - *t2);
pn2vol_(dt2, dp2, &m2, t2, &pa2,
&sdm2, &sdh2, &c[HALFVOL], &zero, &dq2, &gi);
}
*mgas = m1 + m2;
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm1 /= 1.00000000000000e-003;
*dm2 /= 1.00000000000000e-003;
*dmctr /= 1.00000000000000e-003;
*mgas /= 1.00000000000000e-003;
}
+285
View File
@@ -0,0 +1,285 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="16.0.0 - 68387-65635 2017">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>24</SUB_ID_MAX>
<DEFAULT_ICON>p2port</DEFAULT_ICON>
<SUB_LABEL>Compressibility + friction submodel of pneumatic pipe (C-R-C)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>7</R_STORES_NUMBER>
<I_STORES_NUMBER>1</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>16</SUB_ID>
<TITLE>diameter of pipe</TITLE>
<VARNAME>diam</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+01</DEF_VALUE>
<VALUE>1.00000000000000e+01</VALUE>
<MIN_VALUE>1.00000000000000e-003</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+007</MAX_VALUE>
<UNITS>mm</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>17</SUB_ID>
<TITLE>pipe length</TITLE>
<VARNAME>le</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+00</DEF_VALUE>
<VALUE>1.00000000000000e+00</VALUE>
<MIN_VALUE>1.00000000000000e-006</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<UNITS>m</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>18</SUB_ID>
<TITLE>relative roughness</TITLE>
<VARNAME>rr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e-05</DEF_VALUE>
<VALUE>1.00000000000000e-05</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e-001</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>19</SUB_ID>
<TITLE>polytropic constant</TITLE>
<VARNAME>k</VARNAME>
<VISIBILITY>(mode == 1)</VISIBILITY>
<DEF_VALUE>1.35000000000000e+00</DEF_VALUE>
<VALUE>1.35000000000000e+00</VALUE>
<MIN_VALUE>5.00000000000000e-001</MIN_VALUE>
<MAX_VALUE>2.00000000000000e+000</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>20</SUB_ID>
<TITLE>thermal exchange coefficient</TITLE>
<VARNAME>kth</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>0.00000000000000e+00</DEF_VALUE>
<VALUE>0.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>J/m**2/K/s</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>21</SUB_ID>
<TITLE>external temperature</TITLE>
<VARNAME>extemp</VARNAME>
<VISIBILITY>(mode == 2)</VISIBILITY>
<DEF_VALUE>2.93150000000000e+02</DEF_VALUE>
<VALUE>2.93150000000000e+02</VALUE>
<MIN_VALUE>1.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+003</MAX_VALUE>
<UNITS>K</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>22</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
<IPARAM>
<SUB_ID>23</SUB_ID>
<TITLE>model</TITLE>
<VARNAME>mode</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>2</DEF_VALUE>
<VALUE>2</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>2</MAX_VALUE>
<ENUM_LIST>
<ENUM>
<ENUM_STRING>polytropic</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>with thermal exchange</ENUM_STRING>
</ENUM>
</ENUM_LIST>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>9</SUB_ID>
<TITLE>enthalpy flow at center of pipe</TITLE>
<VARNAME>dhctr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>J/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>mass flow at center of pipe</TITLE>
<VARNAME>dmctr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>g/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>24</SUB_ID>
<TITLE>mass of gas in pipe</TITLE>
<VARNAME>mgas</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>g</UNITS>
</IVAR>
<IVAR>
<SUB_ID>12</SUB_ID>
<TITLE>Reynolds number</TITLE>
<VARNAME>re</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
<IVAR>
<SUB_ID>13</SUB_ID>
<TITLE>mass flow parameter (cm)</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>14</SUB_ID>
<TITLE>mean gas velocity</TITLE>
<VARNAME>v</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>15</SUB_ID>
<TITLE>friction factor</TITLE>
<VARNAME>ff</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>temperature at port 1</TITLE>
<VARNAME>t1</VARNAME>
<VARNAME2>dt1</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>K</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<DEF_VALUE>2.93150000000000e+002</DEF_VALUE>
<VALUE>2.93150000000000e+002</VALUE>
</EVAR>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>pressure at port 1</TITLE>
<VARNAME>p1</VARNAME>
<VARNAME2>dp1</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>Pa</UNITS>
<MIN_VALUE>-1.01300000000000e+005</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+012</MAX_VALUE>
<DEF_VALUE>0.00000000000000e+000</DEF_VALUE>
<VALUE>0.00000000000000e+000</VALUE>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>enthalpy flow rate at port 1</TITLE>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>mass flow rate at port 1</TITLE>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>t2</VARNAME>
<VARNAME2>dt2</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>K</UNITS>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<DEF_VALUE>2.93150000000000e+002</DEF_VALUE>
<VALUE>2.93150000000000e+002</VALUE>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>p2</VARNAME>
<VARNAME2>dp2</VARNAME2>
<VISIBILITY>True</VISIBILITY>
<TYPE>1</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>Pa</UNITS>
<MIN_VALUE>-1.01300000000000e+005</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+012</MAX_VALUE>
<DEF_VALUE>0.00000000000000e+000</DEF_VALUE>
<VALUE>0.00000000000000e+000</VALUE>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>g/s</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+224
View File
@@ -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;
}
+185
View File
@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="14.0.0 - 42489-40361 2015">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>18</SUB_ID_MAX>
<DEFAULT_ICON>p2port</DEFAULT_ICON>
<SUB_LABEL>Friction submodel of pneumatic pipe (R)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>5</R_STORES_NUMBER>
<I_STORES_NUMBER>1</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>13</SUB_ID>
<TITLE>diameter of pipe</TITLE>
<VARNAME>diam</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+01</DEF_VALUE>
<VALUE>1.00000000000000e+01</VALUE>
<MIN_VALUE>1.00000000000000e-003</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+007</MAX_VALUE>
<UNITS>mm</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>14</SUB_ID>
<TITLE>pipe length</TITLE>
<VARNAME>le</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e+00</DEF_VALUE>
<VALUE>1.00000000000000e+00</VALUE>
<MIN_VALUE>1.00000000000000e-006</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+004</MAX_VALUE>
<UNITS>m</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>15</SUB_ID>
<TITLE>relative roughness</TITLE>
<VARNAME>rr</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1.00000000000000e-05</DEF_VALUE>
<VALUE>1.00000000000000e-05</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e-001</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>16</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>9</SUB_ID>
<TITLE>Reynolds number</TITLE>
<VARNAME>re</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>mass flow parameter (cm)</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>11</SUB_ID>
<TITLE>mean gas velocity</TITLE>
<VARNAME>v</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
<IVAR>
<SUB_ID>12</SUB_ID>
<TITLE>friction factor</TITLE>
<VARNAME>ff</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>17</SUB_ID>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>1</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>18</SUB_ID>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>1</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>temperature at port 1</TITLE>
<VARNAME>t1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>pressure at port 1</TITLE>
<VARNAME>p1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>t2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>p2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+240
View File
@@ -0,0 +1,240 @@
/* Submodel PNOR001 skeleton created by AME Submodel editing utility
lun. 10. juil. 17:22:57 2017 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNOR001
------------------------------------------------------------------------------
DATE OF CREATION / AUTHOR :
2002 : Created by FS from PNOR01
------------------------------------------------------------------------------
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_ "PNOR001"
/* >>>>>>>>>>>>Insert Private Code Here. */
/* real stores */
#define PATM 0
#define AREA 1
#define CQ 2
/* integer stores */
#define DISC_ORIF 0
/* <<<<<<<<<<<<End of Private Code. */
/* There are 4 real parameters:
cq flow coefficient (Cq) [null]
area orifice area [mm**2 -> m**2]
Cv flow coefficient (Cv) [null]
Kv flow coefficient (Kv) [null]
*/
/* There are 2 integer parameters:
gi gas type index
flowset flow coefficient setting
*/
void pnor001in_(int *n, double rp[4], int ip[2], double c[3]
, int ic[1])
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi, flowset;
double cq, area, Cv, Kv;
gi = ip[0];
flowset = ip[1];
cq = rp[0];
area = rp[1];
Cv = rp[2];
Kv = rp[3];
loop = 0;
error = 0;
/*
If necessary, check values of the following:
rp[0..3]
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (flowset == 1)
{
if (area < 0.0)
{
error = 2;
amefprintf(stderr, "\nOrifice area should be positive.\n");
}
if (cq <= 0.0)
{
error = 2;
amefprintf(stderr, "\nFlow coefficient should be strictly positive.\n");
}
}
else if (flowset == 2)
{
if (Cv < 0.0)
{
error = 2;
amefprintf(stderr, "\nFlow coefficient (Cv) should be positive (value is %g).\n", Cv);
}
}
else
{
if (Kv < 0.0)
{
error = 2;
amefprintf(stderr, "\nFlow coefficient (Kv) should be positive (value is %g).\n", Kv);
}
}
/* <<<<<<<<<<<<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;
}
if (flowset < 1 || flowset > 3)
{
amefprintf(stderr, "\nflow coefficient setting must be in range [1..3].\n");
error = 2;
}
SUBMODEL_HANDLE_AND_RESET_ERROR(_SUBMODELNAME_, n, error)
/* Common -> SI units conversions. */
rp[1] *= 1.00000000000000e-006;
area = rp[1];
/* >>>>>>>>>>>>Initialization Function Executable Statements. */
/* get atmospheric pressure */
c[PATM] = pn2getatp_();
if (flowset == 1)
{
c[CQ] = cq;
c[AREA] = area;
}
else
{
/* calculation of equivalent area with Cv or Kv.
Default value of cq; the same value will be used in pn2rcqfix. */
c[CQ] = 0.72;
if (flowset == 2) /* Cv */
orif_areafromcv_(&Cv, &c[CQ], &c[AREA]);
else
orif_areafromkv_(&Kv, &c[CQ], &c[AREA]);
}
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 2 ports.
Port 1 has 4 variables:
1 dh1 enthalpy flow rate at port 1 [J/s -> W] basic variable output
2 dm1 mass flow rate at port 1 [g/s -> kg/s] basic variable output
3 temp1 temperature at port 1 [K] basic variable input
4 press1 pressure at port 1 [Pa] basic variable input
Port 2 has 4 variables:
1 dh2 duplicate of dh1 (sign reversed)
2 dm2 duplicate of dm1 (sign reversed)
3 temp2 temperature at port 2 [K] basic variable input
4 press2 pressure at port 2 [Pa] basic variable input
*/
/* There are 2 internal variables.
1 cm mass flow parameter (cm) [(kg*K/J)**(1/2)] basic variable
2 gasvel vena contracta gas velocity [m/s] basic variable
*/
void pnor001_(int *n, double *dh1, double *dm1, double *temp1
, double *press1, double *temp2, double *press2, double *cm
, double *gasvel, double rp[4], int ip[2], double c[3]
, int ic[1])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
double pressa1, pressa2;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi, flowset;
double cq, area, Cv, Kv;
gi = ip[0];
flowset = ip[1];
cq = rp[0];
area = rp[1];
Cv = rp[2];
Kv = rp[3];
loop = 0;
/*
Set all submodel outputs below:
*dh1 = ??;
*dm1 = ??;
*cm = ??;
*gasvel = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressures */
pressa1 = *press1 + c[PATM];
pressa2 = *press2 + c[PATM];
/* calculation of the flows */
pn2rcqfix_( dh1, dm1, temp1, &pressa1, temp2, &pressa2, &c[AREA], &c[CQ], &gi,
cm, gasvel, &ic[DISC_ORIF]);
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm1 /= 1.00000000000000e-003;
}
+199
View File
@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="14.0.0 - 42489-40361 2015">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>18</SUB_ID_MAX>
<DEFAULT_ICON>pn_orifice</DEFAULT_ICON>
<SUB_LABEL>pneumatic orifice (constant flow coefficient)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>3</R_STORES_NUMBER>
<I_STORES_NUMBER>1</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>12</SUB_ID>
<TITLE>flow coefficient (Cq)</TITLE>
<VARNAME>cq</VARNAME>
<VISIBILITY>flowset==1</VISIBILITY>
<DEF_VALUE>7.20000000000000e-01</DEF_VALUE>
<VALUE>7.20000000000000e-01</VALUE>
<MIN_VALUE>1.00000000000000e-010</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+000</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>11</SUB_ID>
<TITLE>orifice area</TITLE>
<VARNAME>area</VARNAME>
<VISIBILITY>flowset==1</VISIBILITY>
<DEF_VALUE>5.00000000000000e+00</DEF_VALUE>
<VALUE>5.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>mm**2</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>17</SUB_ID>
<TITLE>flow coefficient (Cv)</TITLE>
<VARNAME>Cv</VARNAME>
<VISIBILITY>flowset==2</VISIBILITY>
<DEF_VALUE>5.00000000000000e-01</DEF_VALUE>
<VALUE>5.00000000000000e-01</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+030</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>18</SUB_ID>
<TITLE>flow coefficient (Kv)</TITLE>
<VARNAME>Kv</VARNAME>
<VISIBILITY>flowset==3</VISIBILITY>
<DEF_VALUE>4.00000000000000e-01</DEF_VALUE>
<VALUE>4.00000000000000e-01</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+030</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>13</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
<IPARAM>
<SUB_ID>14</SUB_ID>
<TITLE>flow coefficient setting</TITLE>
<VARNAME>flowset</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>3</MAX_VALUE>
<ENUM_LIST>
<ENUM>
<ENUM_STRING>Cq</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>Cv</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>Kv</ENUM_STRING>
</ENUM>
</ENUM_LIST>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>9</SUB_ID>
<TITLE>mass flow parameter (cm)</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>vena contracta gas velocity</TITLE>
<VARNAME>gasvel</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>enthalpy flow rate at port 1</TITLE>
<VARNAME>dh1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>mass flow rate at port 1</TITLE>
<VARNAME>dm1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>temperature at port 1</TITLE>
<VARNAME>temp1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>pressure at port 1</TITLE>
<VARNAME>press1</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>5</SUB_ID>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>6</SUB_ID>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>0</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>temp2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>press2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
+254
View File
@@ -0,0 +1,254 @@
/* Submodel PNVO001 skeleton created by AME Submodel editing utility
ven. 6. oct. 11:10:58 2017 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ameutils.h"
/* *******************************************************************************
TITLE : PNVO001
------------------------------------------------------------------------------
DATE OF CREATION / AUTHOR :
2002 : Created by FS from PNVO01
------------------------------------------------------------------------------
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_ "PNVO001"
/* >>>>>>>>>>>>Insert Private Code Here. */
/* real stores */
#define PATM 0
#define AREAMAX 1
#define CQ 2
/* integer stores */
#define DISC_LIMIT 0
#define DISC_ORIF 1
/* <<<<<<<<<<<<End of Private Code. */
/* There are 4 real parameters:
cq flow coefficient (Cq) [null]
area0 orifice area at maximum opening [mm**2 -> m**2]
Cv maximum flow coefficient (Cv) [null]
Kv maximum flow coefficient (Kv) [null]
*/
/* There are 2 integer parameters:
gi gas type index
flowset flow coefficient setting
*/
void pnvo001in_(int *n, double rp[4], int ip[2], double c[3]
, int ic[2])
{
int loop, error;
/* >>>>>>>>>>>>Extra Initialization Function Declarations Here. */
/* <<<<<<<<<<<<End of Extra Initialization declarations. */
int gi, flowset;
double cq, area0, Cv, Kv;
gi = ip[0];
flowset = ip[1];
cq = rp[0];
area0 = rp[1];
Cv = rp[2];
Kv = rp[3];
loop = 0;
error = 0;
/*
If necessary, check values of the following:
rp[0..3]
*/
/* >>>>>>>>>>>>Initialization Function Check Statements. */
pn2_valid_gas_(&gi, &error);
if (flowset == 1)
{
if (area0 < 0.0)
{
error = 2;
amefprintf(stderr, "\nOrifice area at maximum opening should be positive.\n");
}
if (cq <= 0.0 )
{
error = 2;
amefprintf(stderr, "\nFlow coefficient should be strictly positive.\n");
}
}
else if (flowset == 2)
{
if (Cv < 0.0)
{
error = 2;
amefprintf(stderr, "\nMaximum flow coefficient (Cv) should be positive (value is %g).\n", Cv);
}
}
else
{
if (Kv < 0.0)
{
error = 2;
amefprintf(stderr, "\nMaximum flow coefficient (Kv) should be positive (value is %g).\n", Kv);
}
}
/* <<<<<<<<<<<<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;
}
if (flowset < 1 || flowset > 3)
{
amefprintf(stderr, "\nflow coefficient setting must be in range [1..3].\n");
error = 2;
}
SUBMODEL_HANDLE_AND_RESET_ERROR(_SUBMODELNAME_, n, error)
/* Common -> SI units conversions. */
rp[1] *= 1.00000000000000e-006;
area0 = rp[1];
/* >>>>>>>>>>>>Initialization Function Executable Statements. */
/* get atmospheric pressure */
c[PATM] = pn2getatp_();
if (flowset == 1)
{
c[CQ] = cq;
c[AREAMAX] = area0;
}
else
{
/* calculation of equivalent maximal area with Cv or Kv.
Default value of cq; the same value will be used in pn2rcqfix. */
c[CQ] = 0.72;
if (flowset == 2) /* Cv */
orif_areafromcv_(&Cv, &c[CQ], &c[AREAMAX]);
else
orif_areafromkv_(&Kv, &c[CQ], &c[AREAMAX]);
}
/* <<<<<<<<<<<<End of Initialization Executable Statements. */
}
/* There are 3 ports.
Port 1 has 1 variable:
1 res input signal [null] 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 temp2 temperature at port 2 [K] basic variable input
4 press2 pressure at port 2 [Pa] basic variable input
Port 3 has 4 variables:
1 dh3 duplicate of dh2 (sign reversed)
2 dm3 duplicate of dm2 (sign reversed)
3 temp3 temperature at port 3 [K] basic variable input
4 press3 pressure at port 3 [Pa] basic variable input
*/
/* There are 3 internal variables.
1 xv fractional opening [null] basic variable
2 cm mass flow parameter (cm) [(kg*K/J)**(1/2)] basic variable
3 gasvel vena contracta gas velocity [m/s] basic variable
*/
void pnvo001_(int *n, double *res, double *dh2, double *dm2
, double *temp2, double *press2, double *temp3, double *press3
, double *xv, double *cm, double *gasvel, double rp[4]
, int ip[2], double c[3], int ic[2])
{
int loop;
/* >>>>>>>>>>>>Extra Calculation Function Declarations Here. */
double marea; /* modulated area */
double pressa2, pressa3;
static double zero = 0.0, one = 1.0;
/* <<<<<<<<<<<<End of Extra Calculation declarations. */
int gi, flowset;
double cq, area0, Cv, Kv;
gi = ip[0];
flowset = ip[1];
cq = rp[0];
area0 = rp[1];
Cv = rp[2];
Kv = rp[3];
loop = 0;
/*
Set all submodel outputs below:
*dh2 = ??;
*dm2 = ??;
*xv = ??;
*cm = ??;
*gasvel = ??;
*/
/* >>>>>>>>>>>>Calculation Function Executable Statements. */
/* set absolute pressure */
pressa2 = *press2 + c[PATM];
pressa3 = *press3 + c[PATM];
*xv = dlimit_(res, &zero, &one, &ic[DISC_LIMIT]);
/* limitation of the modulated area */
marea = *xv * c[AREAMAX];
/*** calculation of the flows ***/
pn2rcqfix_( dh2, dm2, temp2, &pressa2, temp3, &pressa3, &marea, &c[CQ], &gi,
cm, gasvel, &ic[DISC_ORIF] );
/* <<<<<<<<<<<<End of Calculation Executable Statements. */
/* SI -> Common units conversions. */
*dm2 /= 1.00000000000000e-003;
}
+220
View File
@@ -0,0 +1,220 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SPE>
<SPE DOC_VERSION="2" AME_VERSION="14.0.0 - 42489-40361 2015">
<SUBMODEL>
<SUB_TYPE>0</SUB_TYPE>
<SUB_ID_MAX>20</SUB_ID_MAX>
<DEFAULT_ICON>pn_morifice</DEFAULT_ICON>
<SUB_LABEL>modulated pneumatic orifice (constant flow coefficient)</SUB_LABEL>
<SUB_UNIT>0</SUB_UNIT>
<R_STORES_NUMBER>3</R_STORES_NUMBER>
<I_STORES_NUMBER>2</I_STORES_NUMBER>
<OUTPUT_TYPE>1</OUTPUT_TYPE>
<RPARAMS_LIST>
<RPARAM>
<SUB_ID>12</SUB_ID>
<TITLE>flow coefficient (Cq)</TITLE>
<VARNAME>cq</VARNAME>
<VISIBILITY>flowset==1</VISIBILITY>
<DEF_VALUE>7.20000000000000e-01</DEF_VALUE>
<VALUE>7.20000000000000e-01</VALUE>
<MIN_VALUE>1.00000000000000e-010</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+000</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>13</SUB_ID>
<TITLE>orifice area at maximum opening</TITLE>
<VARNAME>area0</VARNAME>
<VISIBILITY>flowset==1</VISIBILITY>
<DEF_VALUE>5.00000000000000e+00</DEF_VALUE>
<VALUE>5.00000000000000e+00</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+006</MAX_VALUE>
<UNITS>mm**2</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>18</SUB_ID>
<TITLE>maximum flow coefficient (Cv)</TITLE>
<VARNAME>Cv</VARNAME>
<VISIBILITY>flowset==2</VISIBILITY>
<DEF_VALUE>5.00000000000000e-01</DEF_VALUE>
<VALUE>5.00000000000000e-01</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+030</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
<RPARAM>
<SUB_ID>19</SUB_ID>
<TITLE>maximum flow coefficient (Kv)</TITLE>
<VARNAME>Kv</VARNAME>
<VISIBILITY>flowset==3</VISIBILITY>
<DEF_VALUE>4.00000000000000e-01</DEF_VALUE>
<VALUE>4.00000000000000e-01</VALUE>
<MIN_VALUE>0.00000000000000e+000</MIN_VALUE>
<MAX_VALUE>1.00000000000000e+030</MAX_VALUE>
<UNITS>null</UNITS>
</RPARAM>
</RPARAMS_LIST>
<IPARAMS_LIST>
<IPARAM>
<SUB_ID>14</SUB_ID>
<TITLE>gas type index</TITLE>
<VARNAME>gi</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>99</MAX_VALUE>
</IPARAM>
<IPARAM>
<SUB_ID>15</SUB_ID>
<TITLE>flow coefficient setting</TITLE>
<VARNAME>flowset</VARNAME>
<VISIBILITY>True</VISIBILITY>
<DEF_VALUE>1</DEF_VALUE>
<VALUE>1</VALUE>
<MIN_VALUE>1</MIN_VALUE>
<MAX_VALUE>3</MAX_VALUE>
<ENUM_LIST>
<ENUM>
<ENUM_STRING>Cq</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>Cv</ENUM_STRING>
</ENUM>
<ENUM>
<ENUM_STRING>Kv</ENUM_STRING>
</ENUM>
</ENUM_LIST>
</IPARAM>
</IPARAMS_LIST>
<IVARS_LIST>
<IVAR>
<SUB_ID>20</SUB_ID>
<TITLE>fractional opening</TITLE>
<VARNAME>xv</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>null</UNITS>
</IVAR>
<IVAR>
<SUB_ID>10</SUB_ID>
<TITLE>mass flow parameter (cm)</TITLE>
<VARNAME>cm</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>(kg*K/J)**(1/2)</UNITS>
</IVAR>
<IVAR>
<SUB_ID>11</SUB_ID>
<TITLE>vena contracta gas velocity</TITLE>
<VARNAME>gasvel</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<UNITS>m/s</UNITS>
</IVAR>
</IVARS_LIST>
<EVARS_LIST>
<PORT>
<EVAR>
<SUB_ID>1</SUB_ID>
<TITLE>input signal</TITLE>
<VARNAME>res</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>null</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>2</SUB_ID>
<TITLE>enthalpy flow rate at port 2</TITLE>
<VARNAME>dh2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>J/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>3</SUB_ID>
<TITLE>mass flow rate at port 2</TITLE>
<VARNAME>dm2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>2</IO>
<UNITS>g/s</UNITS>
</EVAR>
<EVAR>
<SUB_ID>4</SUB_ID>
<TITLE>temperature at port 2</TITLE>
<VARNAME>temp2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>5</SUB_ID>
<TITLE>pressure at port 2</TITLE>
<VARNAME>press2</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
<PORT>
<EVAR>
<SUB_ID>6</SUB_ID>
<VARNAME>dh3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>1</PRIMARY_PORT>
<PRIMARY_VAR>0</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>7</SUB_ID>
<VARNAME>dm3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>4</TYPE>
<PRIMARY_PORT>1</PRIMARY_PORT>
<PRIMARY_VAR>1</PRIMARY_VAR>
<DUP_TYPE>1</DUP_TYPE>
</EVAR>
<EVAR>
<SUB_ID>8</SUB_ID>
<TITLE>temperature at port 3</TITLE>
<VARNAME>temp3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>K</UNITS>
</EVAR>
<EVAR>
<SUB_ID>9</SUB_ID>
<TITLE>pressure at port 3</TITLE>
<VARNAME>press3</VARNAME>
<VISIBILITY>True</VISIBILITY>
<TYPE>0</TYPE>
<DIMENSION>1</DIMENSION>
<IO>1</IO>
<UNITS>Pa</UNITS>
</EVAR>
</PORT>
</EVARS_LIST>
<SUBIDS_RESET>0</SUBIDS_RESET>
</SUBMODEL>
</SPE>
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.