2023-09-20 14:25:41 -04:00
|
|
|
c Fortran 77 demo
|
|
|
|
|
c ===============
|
2003-04-14 17:57:48 +00:00
|
|
|
c
|
2023-09-20 14:25:41 -04:00
|
|
|
c This program uses functions defined in :doc:`demo_ftnlib.cpp
|
|
|
|
|
c <demo_ftnlib>` to create an ideal gas mixture and print some of
|
|
|
|
|
c its properties.
|
2003-09-08 15:56:51 +00:00
|
|
|
c
|
2023-09-20 14:25:41 -04:00
|
|
|
c For a C++ version of this program, see :doc:`demo.cpp
|
|
|
|
|
c <../cxx/demo>`.
|
2003-04-14 17:57:48 +00:00
|
|
|
c
|
2021-02-24 09:53:57 -05:00
|
|
|
c Replace this sample main program with your program
|
2022-04-01 22:14:08 -04:00
|
|
|
c
|
2023-09-20 14:25:41 -04:00
|
|
|
c .. tags:: Fortran 77, tutorial, thermodynamics, kinetics,
|
|
|
|
|
c transport
|
2021-02-24 09:53:57 -05:00
|
|
|
|
2021-02-24 10:50:14 -05:00
|
|
|
c This file is part of Cantera. See License.txt in the top-level directory or
|
|
|
|
|
c at https://cantera.org/license.txt for license and copyright information.
|
|
|
|
|
|
2003-04-14 17:57:48 +00:00
|
|
|
program demo
|
|
|
|
|
implicit double precision (a-h,o-z)
|
|
|
|
|
parameter (MAXSP = 20, MAXRXNS = 100)
|
2003-04-17 08:59:07 +00:00
|
|
|
double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
|
2003-09-08 15:56:51 +00:00
|
|
|
double precision diff(MAXSP)
|
2003-04-17 08:59:07 +00:00
|
|
|
character*80 eq
|
2003-09-08 15:56:51 +00:00
|
|
|
character*20 name
|
2003-04-14 17:57:48 +00:00
|
|
|
c
|
2003-11-19 10:50:32 +00:00
|
|
|
write(*,*)
|
|
|
|
|
write(*,*) '******** Fortran 77 Test Program ********'
|
2003-09-06 14:38:49 +00:00
|
|
|
|
2023-03-10 19:34:00 -05:00
|
|
|
call newIdealGasMix('h2o2.yaml','ohmech','mixture-averaged')
|
2003-04-14 17:57:48 +00:00
|
|
|
t = 1200.0
|
|
|
|
|
p = 101325.0
|
2003-04-17 08:59:07 +00:00
|
|
|
call setState_TPX_String(t, p,
|
|
|
|
|
$ 'H2:2, O2:1, OH:0.01, H:0.01, O:0.01')
|
|
|
|
|
|
2003-09-06 14:38:49 +00:00
|
|
|
c
|
|
|
|
|
write(*,*) 'Initial state properties:'
|
|
|
|
|
write(*,10) temperature(), pressure(), density(),
|
|
|
|
|
$ enthalpy_mole(), entropy_mole(), cp_mole()
|
2019-12-29 18:31:43 -05:00
|
|
|
|
2023-09-20 14:25:41 -04:00
|
|
|
c %%
|
|
|
|
|
c Compute the equilibrium state
|
|
|
|
|
c -----------------------------
|
|
|
|
|
c
|
|
|
|
|
c Hold the specific enthalpy and pressure constant.
|
2003-09-06 14:38:49 +00:00
|
|
|
call equilibrate('HP')
|
2003-04-17 08:59:07 +00:00
|
|
|
|
2003-09-06 14:38:49 +00:00
|
|
|
write(*,*) 'Equilibrium state properties:'
|
2003-04-14 17:57:48 +00:00
|
|
|
write(*,10) temperature(), pressure(), density(),
|
|
|
|
|
$ enthalpy_mole(), entropy_mole(), cp_mole()
|
2003-09-06 14:38:49 +00:00
|
|
|
|
2003-04-17 08:59:07 +00:00
|
|
|
10 format(//'Temperature: ',g14.5,' K'/
|
|
|
|
|
$ 'Pressure: ',g14.5,' Pa'/
|
|
|
|
|
$ 'Density: ',g14.5,' kg/m3'/
|
|
|
|
|
$ 'Molar Enthalpy:',g14.5,' J/kmol'/
|
|
|
|
|
$ 'Molar Entropy: ',g14.5,' J/kmol-K'/
|
|
|
|
|
$ 'Molar cp: ',g14.5,' J/kmol-K'//)
|
|
|
|
|
|
|
|
|
|
|
2023-09-20 14:25:41 -04:00
|
|
|
c %%
|
2003-04-17 08:59:07 +00:00
|
|
|
c Reaction information
|
2023-09-20 14:25:41 -04:00
|
|
|
c --------------------
|
2003-04-14 17:57:48 +00:00
|
|
|
c
|
2003-04-17 08:59:07 +00:00
|
|
|
irxns = nReactions()
|
2003-09-06 14:38:49 +00:00
|
|
|
|
|
|
|
|
c forward and reverse rates of progress should be equal
|
|
|
|
|
c in equilibrium states
|
2003-04-17 08:59:07 +00:00
|
|
|
call getFwdRatesOfProgress(qf)
|
|
|
|
|
call getRevRatesOfProgress(qr)
|
2003-09-06 14:38:49 +00:00
|
|
|
|
|
|
|
|
c net rates of progress should be zero in equilibrium states
|
2003-04-17 08:59:07 +00:00
|
|
|
call getNetRatesOfProgress(q)
|
2003-09-06 14:38:49 +00:00
|
|
|
|
|
|
|
|
c for each reaction, print the equation and the rates of progress
|
2003-04-17 08:59:07 +00:00
|
|
|
do i = 1,irxns
|
|
|
|
|
call getReactionEqn(i,eq)
|
|
|
|
|
write(*,20) eq,qf(i),qr(i),q(i)
|
2003-09-06 14:38:49 +00:00
|
|
|
20 format(a27,3e14.5,' kmol/m3/s')
|
2003-04-17 08:59:07 +00:00
|
|
|
end do
|
2003-09-06 14:38:49 +00:00
|
|
|
|
2023-09-20 14:25:41 -04:00
|
|
|
c %%
|
2003-09-08 15:56:51 +00:00
|
|
|
c Transport properties
|
2023-09-20 14:25:41 -04:00
|
|
|
c --------------------
|
2003-09-08 15:56:51 +00:00
|
|
|
dnu = viscosity()
|
|
|
|
|
dlam = thermalConductivity()
|
|
|
|
|
call getMixDiffCoeffs(diff)
|
|
|
|
|
|
|
|
|
|
write(*,30) dnu, dlam
|
|
|
|
|
30 format(//'Viscosity: ',g14.5,' Pa-s'/
|
|
|
|
|
$ 'Thermal conductivity: ',g14.5,' W/m/K'/)
|
|
|
|
|
write(*,*) 'Species ',
|
|
|
|
|
$ ' Diffusion Coefficient'
|
|
|
|
|
nsp = nSpecies()
|
|
|
|
|
do k = 1, nsp
|
|
|
|
|
call getSpeciesName(k, name)
|
|
|
|
|
write(*,40) name, diff(k)
|
|
|
|
|
40 format(' ',a20,e14.5,' m2/s')
|
|
|
|
|
end do
|
|
|
|
|
|
2003-04-14 17:57:48 +00:00
|
|
|
end
|