Federico Zenith ha scritto:
Hi,
I have run into a little hiccup in my code. I have a function to express the
specific heat for gaseous methanol as a function of temperature:
cp(T) = f(T)
I would need to integrate this in temperature so that I can get the enthalpy:
h(T) = int_298.25^T cp(T)
however, the cp(T) function is not particularly nice (see Perry's Chemical
Engineers' Handbook, 2-171), and I cannot solve it analytically by hand (well
maybe it's possible, but I'm lazy). I want therefore to integrate it
numerically.
In Matlab there is a handy quadrature function:
quad( @cp_ch3oh_gas, 298.15, T )
Is there anything similar in Modelica, in order to integrate through a
variable that is not time? Or do I have to write an algorithm by hand?
I'm afraid there is nothing like a quad() function in Modelica, there
are only ways to specify partial derivatives. One of the reasons might
be that it is relatively straightforward to compute derivatives
analytically, while this is not always the case for definite integrals.
Francesco
---------------------------------------------
The code is:
function cp_ch3oh_gas
import Modelica.Math.*;
input Real T(unit="K", min=200.0, max=1500.0);
output Real cp(unit="J/mol K");
protected
constant Real C1 = 0.3925E5;
constant Real C2 = 0.879E5;
constant Real C3 = 1.9165E3;
constant Real C4 = 0.5365E5;
constant Real C5 = 896.7;
algorithm
cp :=( C1 + C2*( C3/T/( sinh(C3/T) ) )^2
+ C4*( C5/T/cosh(C5/T) )^2 ) / 1000;
end cp_ch3oh_gas;
--
Francesco Casella - Ph.D.
Dipartimento di Elettronica e Informazione
Politecnico di Milano
Via Ponzio 34/5
I-20133 MILANO - ITALY
Tel: +39-02-2399-3465 (Leonardo)
+39-02-2399-7749 (Polo di Cremona)
Fax: +39-02-2399-3412
e-mail: [EMAIL PROTECTED]
web: http://home.dei.polimi.it/casella
Skype: callto://francesco.casella