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

Thermodroid HD - язык макросов

Переменные
Переменные объявляются автоматически при появлении в тексте макроса. Например:
v=10.2
автоматически объявляет переменную v, и присваивает ей значение 10.2
Имена переменных не чувствительны к регистру.
V то же, что и v

Операторы

Суммирование
-
Вычитание
/
Деление
*
Умножение
^
Возведение в степень: 2^3=8; 4^0.5=2

"." - точка, разделитель

Математические операции

cos(Arg)
вычисляет косинус аргумента Arg. Arg в радианах

sin(Arg)
вычисляет синус Arg. Arg в радианах

tan(Arg)
вычисляет тангенс Arg. Arg в радианах

acos(Arg)
возвращает арккосинус для Arg. Arg должен быть задан в пределах -1 и 1. Значение будет возвращено в пределах [0..Pi], в радианах

asin(Arg)
возвращает арксинус для Arg. Arg должен быть задан в пределах -1 и 1. Значение будет возвращено в пределах [-Pi/2..Pi/2], в радианах

exp(Arg)
возвращает значение возведения e в степеь Arg, где e - основание натурального логарифма

ln(Arg)
возвращает натуральных логарифм (ln(e) = 1) выражения Arg

abs(Arg)
возвращает модуль Arg

sqr(Arg)
возвращает квадрат Arg

sqrt(Arg) 
возвращает корень Arg

Операции с веществами (fluids)

инициализировать новое вещество
newfluid(#,fluid)
# - номер вещества во внутреннем массиве [0..9]
fluid - имя вещества на английском. например - methane, ethane, nitrogen и т.п.

вычислить состояние вещества при давлении P [Па] и температуре T [K]
fluid#.ptflash(P,T)
# - номер вещества

вычислить состояние вещества при давлении P [Па] и паросодержании V
fluid#.pvflash(P,V)
# - номер вещества

вычислить состояние вещества при температуре T [K] и паросодержании V
fluid#.tvflash(T,V)
# - номер вещества

вычислить состояние вещества при давлении P [Па] и молярной энтальпии H [кДж/кмоль]
fluid#.phflash(P,H)
# - номер вещества

чтобы получить свойство вещества используйте функции:
fluid#.massenthalpy() - получить значение удельной массовой энтальпии [кДж/кг]
fluid#.molarenthalpy() - мольной энтальпии [кДж/кмоль]
fluid#.massentropy() - массовой энтропии [кДж/кг/K]
fluid#.molarentropy() - мольной энтропии [кДж/кмоль/K]
fluid#.massdensity() - плотности [кг/m3]
fluid#.molardensity() - мольной плотности [кмоль/м3]
fluid#.massheatofvap() - удельная энергия парообразования при давлении вещества [кДж/кг]
fluid#.molarheatofvap() - удельная мольная энергия парообразования при давлении вещества [кДж/кмоль]
fluid#.molarweight() - молярная масса [кг/кмоль]
fluid#.t() - температура [K]
fluid#.p() - давление [Па]
fluid#.v() - паросодержание

Пример #1
Вычислить температуру насыщения метана при 2 барах

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

объяснение примера:
newfluid(0,methane) 'эта операция инициализирует новое вещество в ячейке №0 и устанавливает, что новое вещество - метан (methane).
fluid0.pvflash(200000,1) 'вычисляет состояние вещества при давлении 2 бара и паросодержании 1
res=fluid0.t()'присваивает переменной res (стандартная переменная, куда записывается последний результат) значение температуры вещества номер 0. Это выражение равнозначно: fluid0.t() - нет необходимости в каком-либо присвоении


Пример #2
Вычислить количества тепла, необходимого для того, чтобы нагреть 1 кг азота от 150 K до 300 K при 1 баре

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

Пример #3
Вычислить простой теплообменник. Вещество №1 - азот, давление 1 бар, входная температура 30 C, выходная температура -70 C, массовый поток 1 кг/с. Второе вещество - аргон, давление 10 бар, начальное состояние - насыщенная жидкоть, массовый поток 0.2 кг/с. Необходимо определить выходную температуру аргона.

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()


Пример #4
Вычислить простой теплообменник. Первое вещество - вода, давление 1 бар, температура на входе 50 C, температура на выходе 10 C. Второе вещество - метан, давлением 3 бара, состояние на входе - насыщенная жидкость, состояние на выходе - насыщенный пар, величина массового потока 0.2 кг/с. Необходимо определить расход воды.

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


вторник, 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