mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Add TallyView.nuclides
This commit is contained in:
parent
050cb6e016
commit
20331519be
2 changed files with 38 additions and 1 deletions
|
|
@ -16,6 +16,10 @@ _dll.openmc_get_tally.errcheck = _error_handler
|
|||
_dll.openmc_tally_id.argtypes = [c_int32, POINTER(c_int32)]
|
||||
_dll.openmc_tally_id.restype = c_int
|
||||
_dll.openmc_tally_id.errcheck = _error_handler
|
||||
_dll.openmc_tally_nuclides.argtypes = [
|
||||
c_int32, POINTER(POINTER(c_int)), POINTER(c_int)]
|
||||
_dll.openmc_tally_nuclides.restype = c_int
|
||||
_dll.openmc_tally_nuclides.errcheck = _error_handler
|
||||
_dll.openmc_tally_results.argtypes = [
|
||||
c_int32, POINTER(POINTER(c_double)), POINTER(c_int*3)]
|
||||
_dll.openmc_tally_results.restype = c_int
|
||||
|
|
@ -39,6 +43,14 @@ class TallyView(object):
|
|||
_dll.openmc_tally_id(self._index, tally_id)
|
||||
return tally_id.value
|
||||
|
||||
@property
|
||||
def nuclides(self):
|
||||
nucs = POINTER(c_int)()
|
||||
n = c_int()
|
||||
_dll.openmc_tally_nuclides(self._index, nucs, n)
|
||||
return [NuclideView(nucs[i]).name if nucs[i] > 0 else 'total'
|
||||
for i in range(n.value)]
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
"""Get tally results array
|
||||
|
|
|
|||
27
src/api.F90
27
src/api.F90
|
|
@ -44,6 +44,7 @@ module openmc_api
|
|||
public :: openmc_reset
|
||||
public :: openmc_run
|
||||
public :: openmc_tally_id
|
||||
public :: openmc_tally_nuclides
|
||||
public :: openmc_tally_results
|
||||
|
||||
! Error codes
|
||||
|
|
@ -335,7 +336,7 @@ contains
|
|||
end function openmc_get_tally
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_LOAD_LOAD loads a nuclide from the cross section library
|
||||
! OPENMC_LOAD_NUCLIDE loads a nuclide from the cross section library
|
||||
!===============================================================================
|
||||
|
||||
function openmc_load_nuclide(name) result(err) bind(C)
|
||||
|
|
@ -657,6 +658,30 @@ contains
|
|||
end if
|
||||
end function openmc_tally_id
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_TALLY_NUCLIDES returns the list of nuclides assigned to a tally
|
||||
!===============================================================================
|
||||
|
||||
function openmc_tally_nuclides(index, ptr, n) result(err) bind(C)
|
||||
integer(C_INT32_T), value :: index
|
||||
type(C_PTR), intent(out) :: ptr
|
||||
integer(C_INT), intent(out) :: n
|
||||
integer(C_INT) :: err
|
||||
|
||||
err = E_UNASSIGNED
|
||||
if (index >= 1 .and. index <= size(tallies)) then
|
||||
associate (t => tallies(index))
|
||||
if (allocated(t % nuclide_bins)) then
|
||||
ptr = C_LOC(t % nuclide_bins(1))
|
||||
n = size(t % nuclide_bins)
|
||||
err = 0
|
||||
end if
|
||||
end associate
|
||||
else
|
||||
err = E_OUT_OF_BOUNDS
|
||||
end if
|
||||
end function openmc_tally_nuclides
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_TALLY_RESULTS returns a pointer to a tally results array along with its
|
||||
! shape. This allows a user to obtain in-memory tally results from Python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue