Skip to content

Commit

Permalink
mubar
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Jun 3, 2024
1 parent 5adcc8e commit e07fc53
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION "3.14")

project(EQUILIBRATE LANGUAGES Fortran C VERSION "0.1.3")
project(EQUILIBRATE LANGUAGES Fortran C VERSION "0.1.4")

set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/modules")
include(cmake/CPM.cmake)
Expand Down
2 changes: 2 additions & 0 deletions equilibrate/cython/ChemEquiAnalysis_pxd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ cdef extern void chemequianalysis_molfracs_atoms_condensate_get(ChemEquiAnalysis
cdef extern void chemequianalysis_molfracs_species_condensate_get_size(ChemEquiAnalysis *ptr, int *dim1)
cdef extern void chemequianalysis_molfracs_species_condensate_get(ChemEquiAnalysis *ptr, int *dim1, double *arr)

cdef extern void chemequianalysis_mubar_get(ChemEquiAnalysis *ptr, double *val)

cdef extern void chemequianalysis_verbose_get(ChemEquiAnalysis *ptr, cbool *val)
cdef extern void chemequianalysis_verbose_set(ChemEquiAnalysis *ptr, cbool *val)

Expand Down
7 changes: 7 additions & 0 deletions equilibrate/cython/_equilibrate.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ cdef class ChemEquiAnalysis:
cea_pxd.chemequianalysis_molfracs_species_condensate_get(self._ptr, &dim1, <double *>arr.data)
return arr

property mubar:
"float. Mean molecular weight (g/mol)."
def __get__(self):
cdef double val
cea_pxd.chemequianalysis_mubar_get(self._ptr, &val)
return val

property verbose:
"bool. Determines amount of printing."
def __get__(self):
Expand Down
9 changes: 9 additions & 0 deletions equilibrate/fortran/equilibrate_c_api.f90
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ subroutine chemequianalysis_molfracs_species_condensate_get(ptr, dim1, arr) bind
arr = cea%molfracs_species_condensate
end subroutine

subroutine chemequianalysis_mubar_get(ptr, val) bind(c)
use equilibrate, only: ChemEquiAnalysis
type(c_ptr), value, intent(in) :: ptr
real(c_double), intent(out) :: val
type(ChemEquiAnalysis), pointer :: cea
call c_f_pointer(ptr, cea)
val = cea%mubar
end subroutine

subroutine chemequianalysis_verbose_get(ptr, val) bind(c)
use equilibrate, only: ChemEquiAnalysis
type(c_ptr), value, intent(in) :: ptr
Expand Down
6 changes: 4 additions & 2 deletions src/equilibrate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ module equilibrate
!! phase (size(condensate_names))

! A few undocumented outputs.
real(dp) :: nabla_ad, gamma2, MMW, rho, c_pe
real(dp) :: nabla_ad, gamma2, rho, c_pe

real(dp) :: mubar !! Mean molecular weight

logical :: verbose = .false. !! Determines amount of printing.
real(dp) :: mass_tol = 1.0e-2_dp !! Degree to which mass will be balanced.
Expand Down Expand Up @@ -245,7 +247,7 @@ function solve(self, P, T, molfracs_atoms, molfracs_species, err) result(converg
molfracs_reactants=self%molfracs_species, &
massfracs_reactants=self%massfracs_species, &
temp=T, press=P_bars, &
nabla_ad=self%nabla_ad, gamma2=self%gamma2, MMW=self%MMW, rho=self%rho, c_pe=self%c_pe)
nabla_ad=self%nabla_ad, gamma2=self%gamma2, MMW=self%mubar, rho=self%rho, c_pe=self%c_pe)
if (self%dat%error) then
err = trim(self%dat%err_msg)
return
Expand Down

0 comments on commit e07fc53

Please sign in to comment.