вторник, 7 февраля 2012 г.

Thermodroid HD macro language

Variables
You can declare variables silenced. It means, that expression:
v=10.2
automatically declares the variable v, and assigns it the value 10.2
The variable name is not case sensitive.
V is the same as v

Operators

Addition
-
Subtraction
/
Division
*
Multiplication
^
Involution: 2^3=8; 4^0.5=2

"." - dot, the decimal separator

Math operations

cos(Arg)
calculate the cosine from Arg. Arg given in radians

sin(Arg)
calculate the sine from Arg. Arg given in radians

tan(Arg)
calculate the tangent from Arg. Arg given in radians

acos(Arg)
returns the inverse cosine of Arg. Arg must be between -1 and 1. The return value is in the range [0..Pi], in radians

asin(Arg)
returns the inverse sine of Arg. Arg must be between -1 and 1. The return value will be in the range [-Pi/2..Pi/2], in radians

exp(Arg)
returns the value of e raised to the power of Arg, where e is the base of the natural logarithms

ln(Arg)
returns the natural logarithm (ln(e) = 1) of the expression Arg

abs(Arg)
returns the absolute value of the argument Arg

sqr(Arg)
function returns the square of the argument Arg

sqrt(Arg) 
the result is the square root of Arg

Fluid operations

to initialize the new fluid
newfluid(#,fluid)
# - number of the fluid in the internal array [0..9]
fluid - the fluid name. for example - methane, ethane, nitrogen and so on.

to calculate the fluid at pressure P [Pa] and temperature T [K]
fluid#.ptflash(P,T)
# - number of the fluid

to calculate the fluid at pressure P [Pa] and vapour fraction V
fluid#.pvflash(P,V)
# - number of the fluid

to calculate the fluid at temperature T [K] and vapour fraction V
fluid#.tvflash(T,V)
# - number of the fluid

to calculate the fluid at pressure P [Pa] and molar enthalpy H [kJ/kmole]
fluid#.phflash(P,H)
# - number of the fluid

to get fluid properies use functions
fluid#.massenthalpy() - get the mass enthalpy value of calculated fluid [kJ/kg]
fluid#.molarenthalpy() - get the molar enthalpy [kJ/kmole]
fluid#.massentropy() - get the mass entropy [kJ/kg/K]
fluid#.molarentropy() - get the molar entropy [kJ/kmole/K]
fluid#.massdensity() - get the mass density [kg/m3]
fluid#.molardensity() - get the molar density [kmole/m3]
fluid#.massheatofvap() - get the heat of evaporation in mass basis [kJ/kg]
fluid#.molarheatofvap() - get the heat of evaporation in molar basis [kJ/kmole]
fluid#.molarweight() - get the molar weight [kg/kmole]
fluid#.t() - get the temperature [K]
fluid#.p() - get the pressure [Pa]
fluid#.v() - get the vapour fraction

Example #1
Calculate the saturation temperature of methane at 2 bar

newfluid(0,methane)
fluid0.pvflash(200000,1)
res=fluid0.t()

the explanation of example:
newfluid(0,methane) 'this operation initializes the new fluid number 0 and sets that the new fluid is methane.
fluid0.pvflash(200000,1) 'calculate the fluid state at pressure 2 bar and vapour fraction 1 (saturated valve)
res=fluid0.t()'assign to the variable res (the standard result holder) the temperature of fluid number 0. this expression equals: fluid0.t() - there is not any assignments to variables


Example #2
Calculate the heat value needed to heat 1 kg of nitrogen from 150 K to 300 K at 1 bar

newfluid(0,nitrogen)
p=100000
fluid0.ptflash(p,150)
h1=fluid0.massenthalpy()
fluid0.ptflash(p,300)
h2=fluid0.massenthalpy()
q=h2-h1

Example #3
Calculate the simple exchanger. First fluid - nitrogen, pressure 1 bar, inlet temperature 30 C, outlet temperature -70 C, massflow 1 kg/s. Second fluid - argon, pressure 10 bar, inlet state - saturated liquid, mass flow 0.2 kg/s. Need to calculate the outlet temperature for argon.

p1=100000
p2=1000000
t1=273.15+30
t2=273.15-70
gn=1
ga=0.2
newfluid(0,nitrogen)
fluid0.ptflash(p1,t1)
hn1=fluid0.molarenthalpy()
fluid0.ptflash(p1,t2)
hn2=fluid0.molarenthalpy()
qn=hn1-hn2
newfluid(1,argon)
fluid1.pvflash(p2,0)
ha1=fluid1.molarenthalpy()
qa=qn*gn/fluid0.molarweight()/ga*fluid1.molarweight()
ha2=ha1+qa
fluid1.phflash(p2,ha2)
ta2=fluid1.t()


Example #4
Calculate the simple exchanger. First fluid - H2O, pressure 1 bar, inlet temperature 50 C, outlet temperature 10 C. Second fluid - methane, pressure 3 bar, inlet state - saturated liquid, outlet state - saturated valve, mass flow 0.2 kg/s. Need to calculate the mass flow for water.

p1=100000
p2=300000
t1=273.15+50
t2=273.15+10
gm=0.2
newfluid(0,h2o)
fluid0.ptflash(p1,t1)
hw1=fluid0.massenthalpy()
fluid0.ptflash(p1,t2)
hw2=fluid0.massenthalpy()
qw=hw1-hw2
newfluid(1,methane)
fluid1.pvflash(p2,0)
hm1=fluid1.massenthalpy()
fluid1.pvflash(p2,1)
hm2=fluid1.massenthalpy()
qm=hm2-hm1
gw=qm*gm/qw


1 комментарий:

  1. This is one of the meaningful and good post.I like your blog details.This is one of the enjoyable post.
    Android app developers

    ОтветитьУдалить