minor changes to fortran files

This commit is contained in:
Dave Goodwin 2004-08-05 17:04:21 +00:00
parent 7db7af9902
commit e2767cf725
3 changed files with 92 additions and 66 deletions

View file

@ -30,10 +30,8 @@ module cantera_funcs
str = ctxml_child(s, 'transport')
call ctxml_getAttrib(str, 'model', model)
if (present(loglevel)) then
write(*,*) 'tr 1'
self%tran_id = newTransport(model, self%thermo_id, loglevel)
else
write(*,*) 'tr 2'
self%tran_id = newTransport(model, self%thermo_id, 0)
end if

View file

@ -604,8 +604,6 @@ extern "C" {
string mstr = f2string(model, lenmodel);
thermo_t* t = _fth(ith);
try {
cout << int(mstr[5]) << endl;
cout << "mstr = >" << mstr << "< " << endl;
Transport* tr = newTransportMgr(mstr, t, *loglevel);
return Storage::storage()->addTransport(tr);
}

View file

@ -4,93 +4,123 @@
! This program uses functions defined in demo_ftnlib.cpp to create
! an ideal gas mixture and print some its properties.
!
! For a C++ version of this program, see ../cxx/demo.cpp.
! For a C++ version of this program, type 'ctnew -cxx'.
!
program main
call demo(100, 500)
stop
end
subroutine demo(maxsp, maxrxns)
! use the Cantera module
use cantera
implicit none
integer, intent(in) :: maxsp
integer, intent(in) :: maxrxns
implicit none
! objects representing phases of matter have type 'phase_t'
type(phase_t) gas
integer nsp, nrxns
double precision :: t, p
write(*,*)
write(*,*) '******** Fortran 90 Test Program ********'
! Read in a definition of the 'gas' phase.
! This will take the definition with name 'ohmech' from file
! 'h2o2.cti', located in the Cantera data directory
gas = importPhase('h2o2.cti','ohmech')
t = 1200.0 ! K
p = 101325.0 ! Pa
! set the temperature, pressure, and mole fractions.
call setState_TPX(gas, t, p, 'H2:1, O2:1, AR:2')
nsp = nSpecies(gas) ! number of species
nrxns = nReactions(gas) ! number of reactions
call demo(gas, nsp, nrxns)
stop
end program main
!--------------------------------------------------------
subroutine demo(gas, MAXSP, MAXRXNS)
! use the Cantera module
use cantera
implicit none
! declare the arguments
type(phase_t), intent(inout) :: gas
integer, intent(in) :: MAXSP
integer, intent(in) :: MAXRXNS
double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
double precision diff(MAXSP)
character*80 eq
character*20 name
double precision :: t, p, dnu, dlam
integer :: i, irxns, nsp, k
write(*,*)
write(*,*) '******** Fortran 90 Test Program ********'
write(*,*) 'Initial state properties:'
write(*,10) temperature(gas), pressure(gas), density(gas), &
enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas)
gas = importPhase('h2o2.cti','ohmech')
! compute the equilibrium state holding the specific
! enthalpy and pressure constant
call equilibrate(gas, HP)
t = 1200.0
p = 101325.0
call setState_TPX(gas, t, p, 'H2:1, O2:1, AR:2')
write(*,*) 'Initial state properties:'
write(*,10) temperature(gas), pressure(gas), density(gas), &
enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas)
! compute the equilibrium state holding the specifi!
! enthalpy and pressure constant
call equilibrate(gas, HP)
write(*,*) 'Equilibrium state properties:'
write(*,10) temperature(gas), pressure(gas), density(gas), &
enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas)
write(*,*) 'Equilibrium state properties:'
write(*,10) temperature(gas), pressure(gas), density(gas), &
enthalpy_mole(gas), entropy_mole(gas), cp_mole(gas)
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'//)
'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'//)
! Reaction information
irxns = nReactions(gas)
! Reaction information
irxns = nReactions(gas)
! forward and reverse rates of progress should be equal
! in equilibrium states
call getFwdRatesOfProgress(gas, qf)
call getRevRatesOfProgress(gas, qr)
! forward and reverse rates of progress should be equal
! in equilibrium states
call getFwdRatesOfProgress(gas, qf)
call getRevRatesOfProgress(gas, qr)
! net rates of progress should be zero in equilibrium states
call getNetRatesOfProgress(gas, q)
! net rates of progress should be zero in equilibrium states
call getNetRatesOfProgress(gas, q)
! for each reaction, print the equation and the rates of progress
do i = 1,irxns
call getReactionString(gas, i,eq)
write(*,20) eq,qf(i),qr(i),q(i)
20 format(a27,3e14.5,' kmol/m3/s')
end do
! for each reaction, print the equation and the rates of progress
do i = 1,irxns
call getReactionString(gas, i,eq)
write(*,20) eq,qf(i),qr(i),q(i)
20 format(a27,3e14.5,' kmol/m3/s')
end do
! Transport properties
dnu = viscosity(gas)
dlam = thermalConductivity(gas)
call getMixDiffCoeffs(gas, diff)
! transport properties
dnu = viscosity(gas)
dlam = thermalConductivity(gas)
call getMixDiffCoeffs(gas, diff)
write(*,30) dnu, dlam
write(*,30) dnu, dlam
30 format(//'Viscosity: ',g14.5,' Pa-s'/ &
'Thermal conductivity: ',g14.5,' W/m/K'/)
'Thermal conductivity: ',g14.5,' W/m/K'/)
write(*,*) 'Species Diffusion Coefficient'
nsp = nSpecies(gas)
do k = 1, nsp
call getSpeciesName(gas, k, name)
write(*,40) name, diff(k)
40 format(' ',a20,e14.5,' m2/s')
end do
write(*,*) 'Species Diffusion Coefficient'
nsp = nSpecies(gas)
do k = 1, nsp
call getSpeciesName(gas, k, name)
write(*,40) name, diff(k)
40 format(' ',a20,e14.5,' m2/s')
end do
return
stop
end subroutine demo