C内核流量计算方法优化,前端文件名称读取优化
This commit is contained in:
1 parent
5d5a2e1843
commit
808c484f5b
94 files changed
+20163
-4418
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user