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?
---------------------------------------------
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;
pgp5seijuGVqb.pgp
Description: PGP signature
