Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions source/mixture.f90
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ function mixture_calc_entropy_single(self, weights, temperature, pressure) resul
s = s + nj*(sj - log(nj))
end if
end do
s = s - n*log(pressure/n)
s = s * gas_constant !/ 1.d3
s = s - n*log(pressure/std_pressure/n)
s = s * gas_constant

end function

Expand Down Expand Up @@ -892,11 +892,11 @@ function mixture_calc_entropy_multi(self, weights, temperatures, pressures) resu
s = s + nj*sj
else
n = n + nj
s = s + nj*(sj - log(nj*pressures(j)))
s = s + nj*(sj - log(nj*pressures(j)/std_pressure))
end if
end do
s = s + n*log(n)
s = s * gas_constant / 1.d3
s = s * gas_constant

end function

Expand Down Expand Up @@ -931,24 +931,26 @@ function mixture_calc_gibbs_energy_multi(self, weights, temperatures, pressures)

! Locals
integer :: j
real(dp) :: gj, nj, n, nr, pr
real(dp) :: gj, nj, n, nr, pr, total_weight

call check_array_len(size(weights), self%num_species, 'mixture_calc_gibbs_energy_multi weights')
call check_array_len(size(temperatures), self%num_species, 'mixture_calc_gibbs_energy_multi temperatures')
call check_array_len(size(pressures), self%num_species, 'mixture_calc_gibbs_energy_multi pressures')

total_weight = sum(weights)

! Must pre-compute because cannot factor out of the
! sum when consitituent temperatures can vary.
n = 0.0d0
do j = 1, self%num_species
if (self%is_condensed(j)) cycle
nj = weights(j)/self%species(j)%molecular_weight
nj = weights(j)/self%species(j)%molecular_weight/total_weight
n = n + nj
end do

g = 0.0d0
do j = 1, self%num_species
nj = weights(j)/self%species(j)%molecular_weight
nj = weights(j)/self%species(j)%molecular_weight/total_weight
gj = self%species(j)%calc_gibbs_energy(temperatures(j))
if (self%is_condensed(j)) then
g = g + nj*gj
Expand Down
8 changes: 4 additions & 4 deletions source/mixture_test.pf
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,16 @@ contains
t = temp(1)
@assertRelativelyEqual(-1.19532599d+07, mix%calc_enthalpy(wtfracs, t), tol)
@assertRelativelyEqual(-1.20517040d+07, mix%calc_energy(wtfracs, t), tol)
!@assertRelativelyEqual(-1.48300159E+07, mix%calc_gibbs_energy(wtfracs, t, p), tol)
!@assertRelativelyEqual( 9.46301312d+03, mix%calc_entropy(wtfracs, t, p), tol)
@assertRelativelyEqual(-1.48300159E+07, mix%calc_gibbs_energy(wtfracs, t, p), tol)
@assertRelativelyEqual( 9.46301312d+03, mix%calc_entropy(wtfracs, t, p), tol)

! Version 2: Allow per-species temperatures and pressures
! This enables fuels and oxidizers to have different initial states
! prior to being mixed and equilibrated.
@assertRelativelyEqual(-1.19532599d+07, mix%calc_enthalpy(wtfracs, temp), tol)
@assertRelativelyEqual(-1.20517040d+07, mix%calc_energy(wtfracs, temp), tol)
!@assertRelativelyEqual(-1.48300159E+07, mix%calc_gibbs_energy(wtfracs, temp, pres), tol)
!@assertRelativelyEqual( 9.46301312d+03, mix%calc_entropy(wtfracs, temp, pres), tol)
@assertRelativelyEqual(-1.48300159E+07, mix%calc_gibbs_energy(wtfracs, temp, pres), tol)
@assertRelativelyEqual( 9.46301312d+03, mix%calc_entropy(wtfracs, temp, pres), tol)

end subroutine

Expand Down
Loading