上传 AMESim 参考资料
This commit is contained in:
1 parent
3f51a124d6
commit
2ddaaeb56a
33 files changed
+6288
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user