C内核按库功能拆解,编译结果缓存区构建,编译过程与已有缓存结果对照功能实现
This commit is contained in:
1 parent
aa4951b14e
commit
151e6e4b97
30 files changed
+4856
-604
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "component_properties_internal.h"
|
||||
#include <math.h>
|
||||
|
||||
int native_orifice(double p1, double p2, double h1, double h2,
|
||||
double cq_area, double opening, double *flow,
|
||||
double *cm, double *velocity) {
|
||||
return native_orifice_context(NULL,p1,p2,h1,h2,cq_area,opening,flow,cm,velocity);
|
||||
}
|
||||
int native_orifice_context(NativePropertyCache *cache,double p1,double p2,double h1,double h2,
|
||||
double cq_area,double opening,double *flow,double *cm,double *velocity) {
|
||||
int forward = p1 >= p2;
|
||||
double p = forward ? p1 : p2, pd = forward ? p2 : p1;
|
||||
double T = native_temperature_ph_context(cache,&helium_medium,fmax(p,1),forward?h1:h2);
|
||||
medium_valve(cache,&helium_medium,p,pd,T,cm,velocity);
|
||||
double sign = forward ? 1 : -1;
|
||||
*velocity *= sign;
|
||||
*flow = opening == 0 || fabs(p1-p2) <= 1e-8 ? 0 :
|
||||
sign * cq_area * opening * fmax(p, 1) * *cm / sqrt(fmax(T, 1));
|
||||
if (opening == 0) *velocity = 0;
|
||||
return isfinite(*flow) && isfinite(*cm) && isfinite(*velocity);
|
||||
}
|
||||
|
||||
int native_medium_orifice(const NativeMedium *m, double p1, double p2, double h1, double h2,
|
||||
double area, double opening, double *q, double *cm, double *v) {
|
||||
return native_medium_orifice_context(NULL,m,p1,p2,h1,h2,area,opening,q,cm,v);
|
||||
}
|
||||
int native_medium_orifice_context(NativePropertyCache *cache,const NativeMedium *m,double p1,double p2,double h1,double h2,
|
||||
double area,double opening,double *q,double *cm,double *v) {
|
||||
double p=fmax(p1,p2),pd=fmin(p1,p2),sign=p1>=p2?1:-1;
|
||||
double T=fmax(native_temperature_ph_context(cache,m,fmax(p,1),p1>=p2?h1:h2),1);
|
||||
medium_valve(cache,m,p,pd,T,cm,v);
|
||||
*q=fabs(p1-p2)<=1e-8?0:sign*area*opening*fmax(p,1)*(*cm)/sqrt(T);
|
||||
*v*=fabs(opening)<=1e-12?0:sign;
|
||||
return isfinite(*q) && isfinite(*cm) && isfinite(*v);
|
||||
}
|
||||
Reference in new issue
Block a user