mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Add openmc_cell_set_temperature
This commit is contained in:
parent
bb6adfca2a
commit
157a45bf5a
4 changed files with 74 additions and 26 deletions
|
|
@ -299,6 +299,7 @@ set(LIBOPENMC_FORTRAN_SRC
|
|||
src/angle_distribution.F90
|
||||
src/angleenergy_header.F90
|
||||
src/bank_header.F90
|
||||
src/capi.F90
|
||||
src/cmfd_data.F90
|
||||
src/cmfd_execute.F90
|
||||
src/cmfd_header.F90
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ class _OpenMCLibrary(object):
|
|||
c_int, POINTER(POINTER(c_double)), ndpointer(
|
||||
np.intc, shape=(3,))]
|
||||
self._dll.openmc_tally_results.restype = None
|
||||
self._dll.openmc_cell_set_temperature.argtypes = [
|
||||
c_int, c_double]
|
||||
self._dll.openmc_cell_set_temperature.restype = c_int
|
||||
|
||||
def init(self, intracomm=None):
|
||||
"""Initialize OpenMC
|
||||
|
|
@ -87,6 +90,10 @@ class _OpenMCLibrary(object):
|
|||
else:
|
||||
return None
|
||||
|
||||
def cell_set_temperature(self, cell_id, temperature):
|
||||
"""Set the temperature of a cell"""
|
||||
return self._dll.openmc_cell_set_temperature(cell_id, temperature)
|
||||
|
||||
def __getattr__(self, key):
|
||||
# Fall-back for other functions that may be available from library
|
||||
try:
|
||||
|
|
|
|||
65
src/capi.F90
Normal file
65
src/capi.F90
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
module openmc_capi
|
||||
|
||||
use, intrinsic :: ISO_C_BINDING
|
||||
|
||||
use constants, only: K_BOLTZMANN
|
||||
use eigenvalue, only: k_sum
|
||||
use global
|
||||
|
||||
private
|
||||
public :: openmc_cell_set_temperature
|
||||
public :: openmc_reset
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_CELL_SET_TEMPERATURE sets the temperature of a cell
|
||||
!===============================================================================
|
||||
|
||||
function openmc_cell_set_temperature(id, T) result(err) bind(C)
|
||||
integer(C_INT), value, intent(in) :: id ! id of cell
|
||||
real(C_DOUBLE), value, intent(in) :: T
|
||||
integer(C_INT) :: err
|
||||
|
||||
integer :: i
|
||||
|
||||
err = -1
|
||||
if (allocated(cells)) then
|
||||
if (cell_dict % has_key(id)) then
|
||||
i = cell_dict % get_key(id)
|
||||
associate (c => cells(i))
|
||||
if (allocated(c % sqrtkT)) then
|
||||
c % sqrtkT(:) = sqrt(K_BOLTZMANN * T)
|
||||
err = 0
|
||||
end if
|
||||
end associate
|
||||
end if
|
||||
end if
|
||||
end function openmc_cell_set_temperature
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_RESET resets all tallies
|
||||
!===============================================================================
|
||||
|
||||
subroutine openmc_reset() bind(C)
|
||||
integer :: i
|
||||
|
||||
do i = 1, size(tallies)
|
||||
tallies(i) % n_realizations = 0
|
||||
if (allocated(tallies(i) % results)) then
|
||||
tallies(i) % results(:, :, :) = ZERO
|
||||
end if
|
||||
end do
|
||||
|
||||
n_realizations = 0
|
||||
if (allocated(global_tallies)) then
|
||||
global_tallies(:, :) = ZERO
|
||||
end if
|
||||
k_col_abs = ZERO
|
||||
k_col_tra = ZERO
|
||||
k_abs_tra = ZERO
|
||||
k_sum(:) = ZERO
|
||||
|
||||
end subroutine openmc_reset
|
||||
|
||||
end module openmc_capi
|
||||
|
|
@ -27,7 +27,7 @@ module simulation
|
|||
|
||||
implicit none
|
||||
private
|
||||
public :: openmc_run, openmc_reset
|
||||
public :: openmc_run
|
||||
|
||||
contains
|
||||
|
||||
|
|
@ -423,29 +423,4 @@ contains
|
|||
|
||||
end subroutine reduce_overlap_count
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_RESET resets all tallies
|
||||
!===============================================================================
|
||||
|
||||
subroutine openmc_reset() bind(C)
|
||||
integer :: i
|
||||
|
||||
do i = 1, size(tallies)
|
||||
tallies(i) % n_realizations = 0
|
||||
if (allocated(tallies(i) % results)) then
|
||||
tallies(i) % results(:, :, :) = ZERO
|
||||
end if
|
||||
end do
|
||||
|
||||
n_realizations = 0
|
||||
if (allocated(global_tallies)) then
|
||||
global_tallies(:, :) = ZERO
|
||||
end if
|
||||
k_col_abs = ZERO
|
||||
k_col_tra = ZERO
|
||||
k_abs_tra = ZERO
|
||||
k_sum(:) = ZERO
|
||||
|
||||
end subroutine openmc_reset
|
||||
|
||||
end module simulation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue