mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Add CMFD helper functions to access entropy_on, is_master, current_batch, implement vector_write
This commit is contained in:
parent
959514e8be
commit
349c2a804b
6 changed files with 50 additions and 6 deletions
|
|
@ -62,6 +62,16 @@ def calculate_volumes():
|
|||
_dll.openmc_calculate_volumes()
|
||||
|
||||
|
||||
def current_batch():
|
||||
"""Return the current batch of the simulation.
|
||||
Returns
|
||||
-------
|
||||
int
|
||||
Current batch of the simulation
|
||||
"""
|
||||
return c_int.in_dll(_dll, 'openmc_current_batch').value
|
||||
|
||||
|
||||
def finalize():
|
||||
"""Finalize simulation and free memory"""
|
||||
_dll.openmc_finalize()
|
||||
|
|
@ -214,6 +224,16 @@ def keff():
|
|||
return (mean, std_dev)
|
||||
|
||||
|
||||
def master():
|
||||
"""Return whether processor is master processor or not.
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
Whether is master processor or not
|
||||
"""
|
||||
return c_bool.in_dll(_dll, 'openmc_master').value
|
||||
|
||||
|
||||
def next_batch():
|
||||
"""Run next batch.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from ctypes import c_int, c_int32, c_int64, c_double, c_char_p, POINTER
|
||||
from ctypes import (c_int, c_int32, c_int64, c_double, c_char_p, c_bool,
|
||||
POINTER)
|
||||
|
||||
from . import _dll
|
||||
from .core import _DLLGlobal
|
||||
|
|
@ -17,6 +18,7 @@ _dll.openmc_get_seed.restype = c_int64
|
|||
class _Settings(object):
|
||||
# Attributes that are accessed through a descriptor
|
||||
batches = _DLLGlobal(c_int32, 'n_batches')
|
||||
entropy_on = _DLLGlobal(c_bool, 'entropy_on')
|
||||
generations_per_batch = _DLLGlobal(c_int32, 'gen_per_batch')
|
||||
inactive = _DLLGlobal(c_int32, 'n_inactive')
|
||||
particles = _DLLGlobal(c_int64, 'n_particles')
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ contains
|
|||
|
||||
! Set the energy bin if needed
|
||||
if (energy_filters) then
|
||||
filter_matches(i_filter_ein) % bins % data(1) = ng - h + 1
|
||||
filter_matches(i_filter_ein) % bins % data(1) = 12*(ng - h) + 1
|
||||
end if
|
||||
|
||||
score_index = 0
|
||||
|
|
|
|||
|
|
@ -146,8 +146,13 @@ contains
|
|||
call loss % assemble()
|
||||
call prod % assemble()
|
||||
if (cmfd_write_matrices) then
|
||||
call loss % write('loss.dat')
|
||||
call prod % write('prod.dat')
|
||||
if (adjoint) then
|
||||
call loss % write('adj_loss.dat')
|
||||
call prod % write('adj_prod.dat')
|
||||
else
|
||||
call loss % write('loss.dat')
|
||||
call prod % write('prod.dat')
|
||||
end if
|
||||
end if
|
||||
|
||||
! Set norms to 0
|
||||
|
|
@ -740,7 +745,7 @@ contains
|
|||
else
|
||||
filename = 'fluxvec.dat'
|
||||
end if
|
||||
! TODO: call phi_n % write(filename)
|
||||
call phi_n % write(filename)
|
||||
end if
|
||||
|
||||
end subroutine extract_results
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ contains
|
|||
|
||||
end subroutine tally_allocate_results
|
||||
|
||||
|
||||
function tally_set_filters(this, filter_indices) result(err)
|
||||
class(TallyObject), intent(inout) :: this
|
||||
integer(C_INT32_T), intent(in) :: filter_indices(:)
|
||||
|
|
@ -1025,6 +1026,7 @@ contains
|
|||
end if
|
||||
end function openmc_tally_set_scores
|
||||
|
||||
|
||||
function openmc_tally_set_type(index, type) result(err) bind(C)
|
||||
! Update the type of a tally that is already allocated
|
||||
integer(C_INT32_T), value, intent(in) :: index
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module vector_header
|
|||
procedure :: destroy => vector_destroy
|
||||
procedure :: add_value => vector_add_value
|
||||
procedure :: copy => vector_copy
|
||||
! TODO: procedure :: write => vector_write
|
||||
procedure :: write => vector_write
|
||||
end type Vector
|
||||
|
||||
contains
|
||||
|
|
@ -88,4 +88,19 @@ contains
|
|||
|
||||
end subroutine vector_copy
|
||||
|
||||
!===============================================================================
|
||||
! VECTOR_WRITE writes a vector to file
|
||||
!===============================================================================
|
||||
subroutine vector_write(self, filename)
|
||||
class(Vector), target, intent(inout) :: self ! vector instance
|
||||
character(*), intent(in) :: filename ! filename to output to
|
||||
integer :: unit_
|
||||
integer :: i
|
||||
open(newunit=unit_, file=filename)
|
||||
do i = 1, self % n
|
||||
write(unit_,*) i, self % data(i)
|
||||
end do
|
||||
close(unit_)
|
||||
end subroutine vector_write
|
||||
|
||||
end module vector_header
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue