Respond to comments on #990. Add FE example notebook.

This commit is contained in:
Paul Romano 2018-04-03 16:54:34 -05:00
parent 964a5da3e2
commit b0a8e81010
8 changed files with 524 additions and 28 deletions

View file

@ -0,0 +1,13 @@
.. _notebook_expansion:
=====================
Functional Expansions
=====================
.. only:: html
.. notebook:: ../../../examples/jupyter/expansion-filters.ipynb
.. only:: latex
IPython notebooks must be viewed in the online HTML documentation.

View file

@ -1,13 +1,12 @@
.. _examples:
=================
Example Notebooks
=================
========
Examples
========
The following series of Jupyter_ Notebooks provide examples for usage of OpenMC
features via the :ref:`pythonapi`.
.. _Jupyter: https://jupyter.org/
The following series of `Jupyter <https://jupyter.org/>`_ Notebooks provide
examples for how to use various features of OpenMC by leveraging the
:ref:`pythonapi`.
-----------
Basic Usage
@ -20,6 +19,7 @@ Basic Usage
post-processing
pandas-dataframes
tally-arithmetic
expansion-filters
search
triso
candu

File diff suppressed because one or more lines are too long

View file

@ -226,17 +226,22 @@ class SpatialLegendreFilter(ExpansionFilter):
class SphericalHarmonicsFilter(ExpansionFilter):
r"""Score spherical harmonic expansion moments up to specified order.
This filter allows you to obtain real spherical harmonic moments of either
the particle's direction or the cosine of the scattering angle. Specifying a
filter with order :math:`\ell` tallies moments for all orders from 0 to
:math:`\ell`.
Parameters
----------
order : int
Maximum spherical harmonics order
Maximum spherical harmonics order, :math:`\ell`
filter_id : int or None
Unique identifier for the filter
Attributes
----------
order : int
Maximum spherical harmonics order
Maximum spherical harmonics order, :math:`\ell`
id : int
Unique identifier for the filter
cosine : {'scatter', 'particle'}

View file

@ -181,7 +181,7 @@ contains
end function calc_pn
!===============================================================================
! CALC_RN calculates the n-th order spherical harmonics for a given angle
! CALC_RN calculates the n-th order real spherical harmonics for a given angle
! (in terms of (u,v,w)). All Rn,m values are provided (where -n<=m<=n)
!===============================================================================

View file

@ -24,7 +24,8 @@ module tally_filter_sph_harm
integer, parameter :: COSINE_PARTICLE = 2
!===============================================================================
! LEGENDREFILTER gives Legendre moments of the change in scattering angle
! SPHERICALHARMONICSFILTER gives spherical harmonics expansion moments of a
! tally score
!===============================================================================
type, public, extends(TallyFilter) :: SphericalHarmonicsFilter
@ -149,7 +150,7 @@ contains
order = f % order
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a spherical harmonics filter.")
end select
end if
end function openmc_sphharm_filter_get_order
@ -183,7 +184,7 @@ contains
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a spherical harmonics filter.")
end select
end if
end function openmc_sphharm_filter_get_cosine
@ -203,7 +204,7 @@ contains
f % n_bins = (order + 1)**2
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to set order on a non-expansion filter.")
call set_errmsg("Not a spherical harmonics filter.")
end select
end if
end function openmc_sphharm_filter_set_order
@ -233,7 +234,7 @@ contains
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a spherical harmonics filter.")
end select
end if
end function openmc_sphharm_filter_set_cosine

View file

@ -25,7 +25,8 @@ module tally_filter_sptl_legendre
integer, parameter :: AXIS_Z = 3
!===============================================================================
! SpatialLEGENDREFILTER gives Legendre moments
! SPATIALLEGENDREFILTER gives Legendre moments of the particle's normalized
! position along an axis
!===============================================================================
type, public, extends(TallyFilter) :: SpatialLegendreFilter
@ -97,18 +98,20 @@ contains
subroutine to_statepoint(this, filter_group)
class(SpatialLegendreFilter), intent(in) :: this
integer(HID_T), intent(in) :: filter_group
character(kind=C_CHAR) :: axis
call write_dataset(filter_group, "type", "spatiallegendre")
call write_dataset(filter_group, "n_bins", this % n_bins)
call write_dataset(filter_group, "order", this % order)
select case (this % axis)
case (AXIS_X)
call write_dataset(filter_group, 'axis', 'x')
axis = 'x'
case (AXIS_Y)
call write_dataset(filter_group, 'axis', 'y')
axis = 'y'
case (AXIS_Z)
call write_dataset(filter_group, 'axis', 'z')
axis = 'z'
end select
call write_dataset(filter_group, 'axis', axis)
call write_dataset(filter_group, 'min', this % min)
call write_dataset(filter_group, 'max', this % max)
end subroutine to_statepoint
@ -118,7 +121,18 @@ contains
integer, intent(in) :: bin
character(MAX_LINE_LEN) :: label
label = "Legendre expansion, P" // trim(to_str(bin - 1))
character(1) :: axis
select case (this % axis)
case (AXIS_X)
axis = 'x'
case (AXIS_Y)
axis = 'y'
case (AXIS_Z)
axis = 'z'
end select
label = "Legendre expansion, " // axis // " axis, P" // &
trim(to_str(bin - 1))
end function text_label
!===============================================================================
@ -138,7 +152,7 @@ contains
order = f % order
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a spatial Legendre filter.")
end select
end if
end function openmc_spatial_legendre_filter_get_order
@ -158,7 +172,7 @@ contains
f % n_bins = order + 1
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to set order on a non-expansion filter.")
call set_errmsg("Not a spatial Legendre filter.")
end select
end if
end function openmc_spatial_legendre_filter_set_order
@ -182,7 +196,7 @@ contains
max = f % max
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to set order on a non-expansion filter.")
call set_errmsg("Not a spatial Legendre filter.")
end select
end if
end function openmc_spatial_legendre_filter_get_params
@ -206,7 +220,7 @@ contains
if (present(max)) f % max = max
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to set order on a non-expansion filter.")
call set_errmsg("Not a spatial Legendre filter.")
end select
end if
end function openmc_spatial_legendre_filter_set_params

View file

@ -129,7 +129,7 @@ contains
order = f % order
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a Zernike filter.")
end select
end if
end function openmc_zernike_filter_get_order
@ -152,7 +152,7 @@ contains
r = f % r
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a Zernike filter.")
end select
end if
end function openmc_zernike_filter_get_params
@ -172,7 +172,7 @@ contains
f % n_bins = ((order + 1)*(order + 2))/2
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to set order on a non-expansion filter.")
call set_errmsg("Not a Zernike filter.")
end select
end if
end function openmc_zernike_filter_set_order
@ -195,7 +195,7 @@ contains
if (present(r)) f % r = r
class default
err = E_INVALID_TYPE
call set_errmsg("Tried to get order on a non-expansion filter.")
call set_errmsg("Not a Zernike filter.")
end select
end if
end function openmc_zernike_filter_set_params