mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Add optional instance argument for openmc_cell_set_temperature
This commit is contained in:
parent
14226862f3
commit
712352c8e1
3 changed files with 27 additions and 8 deletions
|
|
@ -8,7 +8,7 @@ C API
|
|||
|
||||
Run a stochastic volume calculation
|
||||
|
||||
.. c:function:: int openmc_cell_set_temperature(int id, double T)
|
||||
.. c:function:: int openmc_cell_set_temperature(int id, double T, int* instance)
|
||||
|
||||
Set the temperature of a cell.
|
||||
|
||||
|
|
@ -16,6 +16,9 @@ C API
|
|||
:type id: int
|
||||
:param T: Temperature in Kelvin
|
||||
:type T: double
|
||||
:param instance: Which instance of the cell. To set the temperature for all
|
||||
instances, pass a null pointer.
|
||||
:type instance: int*
|
||||
:return: Return status (negative if an error occurred)
|
||||
:rtype: int
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class OpenMCLibrary(object):
|
|||
"""Run stochastic volume calculation"""
|
||||
return self._dll.openmc_calculate_volumes()
|
||||
|
||||
def cell_set_temperature(self, cell_id, T):
|
||||
def cell_set_temperature(self, cell_id, T, instance=None):
|
||||
"""Set the temperature of a cell
|
||||
|
||||
Parameters
|
||||
|
|
@ -75,9 +75,16 @@ class OpenMCLibrary(object):
|
|||
ID of the cell
|
||||
T : float
|
||||
Temperature in K
|
||||
instance : int or None
|
||||
Which instance of the cell
|
||||
|
||||
"""
|
||||
return self._dll.openmc_cell_set_temperature(cell_id, T)
|
||||
if instance is not None:
|
||||
return self._dll.openmc_cell_set_temperature(
|
||||
cell_id, T, byref(c_int(instance)))
|
||||
else:
|
||||
return self._dll.openmc_cell_set_temperature(cell_id, T, None)
|
||||
|
||||
|
||||
def finalize(self):
|
||||
"""Finalize simulation and free memory"""
|
||||
|
|
|
|||
19
src/api.F90
19
src/api.F90
|
|
@ -41,12 +41,13 @@ contains
|
|||
! OPENMC_CELL_SET_TEMPERATURE sets the temperature of a cell
|
||||
!===============================================================================
|
||||
|
||||
function openmc_cell_set_temperature(id, T) result(err) bind(C)
|
||||
function openmc_cell_set_temperature(id, T, instance) result(err) bind(C)
|
||||
integer(C_INT), value, intent(in) :: id ! id of cell
|
||||
real(C_DOUBLE), value, intent(in) :: T
|
||||
integer(C_INT), optional, intent(in) :: instance
|
||||
integer(C_INT) :: err
|
||||
|
||||
integer :: i
|
||||
integer :: i, n
|
||||
|
||||
err = -1
|
||||
if (allocated(cells)) then
|
||||
|
|
@ -54,8 +55,16 @@ contains
|
|||
i = cell_dict % get_key(id)
|
||||
associate (c => cells(i))
|
||||
if (allocated(c % sqrtkT)) then
|
||||
c % sqrtkT(:) = sqrt(K_BOLTZMANN * T)
|
||||
err = 0
|
||||
n = size(c % sqrtkT)
|
||||
if (present(instance) .and. n > 1) then
|
||||
if (instance >= 0 .and. instance < n) then
|
||||
c % sqrtkT(instance + 1) = sqrt(K_BOLTZMANN * T)
|
||||
err = 0
|
||||
end if
|
||||
else
|
||||
c % sqrtkT(:) = sqrt(K_BOLTZMANN * T)
|
||||
err = 0
|
||||
end if
|
||||
end if
|
||||
end associate
|
||||
end if
|
||||
|
|
@ -92,7 +101,7 @@ contains
|
|||
id = materials(p % material) % id
|
||||
end if
|
||||
end if
|
||||
instance = p % cell_instance
|
||||
instance = p % cell_instance - 1
|
||||
end if
|
||||
end subroutine openmc_find
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue