forked from CambridgeNuclear/SCONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CambridgeNuclear#126 from valeriaRaffuzzi/densityR…
…esponse Density response
- Loading branch information
Showing
10 changed files
with
236 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module densityResponse_test | ||
|
||
use numPrecision | ||
use universalVariables, only : neutronMass, lightSpeed | ||
use densityResponse_class, only : densityResponse | ||
use particle_class, only : particle, P_NEUTRON, P_PHOTON | ||
use dictionary_class, only : dictionary | ||
use nuclearDatabase_inter, only : nuclearDatabase | ||
use pFUnit_mod | ||
|
||
implicit none | ||
|
||
@testCase | ||
type, extends(TestCase) :: test_densityResponse | ||
private | ||
type(densityResponse) :: response | ||
contains | ||
procedure :: setUp | ||
procedure :: tearDown | ||
end type test_densityResponse | ||
|
||
|
||
contains | ||
|
||
!! | ||
!! Sets up test_densityResponse object we can use in a number of tests | ||
!! | ||
subroutine setUp(this) | ||
class(test_densityResponse), intent(inout) :: this | ||
type(dictionary) :: tempDict | ||
|
||
end subroutine setUp | ||
|
||
!! | ||
!! Kills test_densityResponse object we can use in a number of tests | ||
!! | ||
subroutine tearDown(this) | ||
class(test_densityResponse), intent(inout) :: this | ||
|
||
end subroutine tearDown | ||
|
||
!!<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> | ||
!! PROPER TESTS BEGIN HERE | ||
!!<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> | ||
|
||
!! | ||
!! Test correct behaviour of the response | ||
!! | ||
@Test | ||
subroutine densityResponseing(this) | ||
class(test_densityResponse), intent(inout) :: this | ||
type(particle) :: p | ||
class(nuclearDatabase),pointer :: xsData | ||
real(defReal) :: res | ||
|
||
! Test neutron density with different particle energies | ||
p % type = P_NEUTRON | ||
p % isMG = .false. | ||
p % E = ONE | ||
res = ONE / lightSpeed / sqrt(TWO * p % E / neutronMass) | ||
@assertEqual(res, this % response % get(p, xsData), res*1.0E-9_defReal) | ||
|
||
p % E = 1.6e-06_defReal | ||
res = ONE / lightSpeed / sqrt(TWO * p % E / neutronMass) | ||
@assertEqual(res, this % response % get(p, xsData), res*1.0E-9_defReal) | ||
|
||
! Test photon density | ||
p % type = P_PHOTON | ||
res = ONE/lightSpeed | ||
@assertEqual(res, this % response % get(p, xsData), res*1.0E-9_defReal) | ||
|
||
end subroutine densityResponseing | ||
|
||
end module densityResponse_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
module densityResponse_class | ||
|
||
use numPrecision | ||
use universalVariables, only : neutronMass, lightSpeed | ||
use dictionary_class, only : dictionary | ||
use particle_class, only : particle, P_NEUTRON, P_PHOTON | ||
use tallyResponse_inter, only : tallyResponse | ||
|
||
! Nuclear Data interface | ||
use nuclearDatabase_inter, only : nuclearDatabase | ||
|
||
implicit none | ||
private | ||
|
||
!! | ||
!! tallyResponse to score particle density contribution | ||
!! | ||
!! Returns the inverse of the particle velocity in [cm/s] | ||
!! | ||
!! NOTE: | ||
!! The velocities are computed from non-relativistic formula for massive particles. | ||
!! The small error might appear in MeV range (e.g. for fusion applications) | ||
!! | ||
!! Interface: | ||
!! tallyResponse Interface | ||
!! | ||
type, public,extends(tallyResponse) :: densityResponse | ||
private | ||
contains | ||
procedure :: init | ||
procedure :: get | ||
procedure :: kill | ||
|
||
end type densityResponse | ||
|
||
contains | ||
|
||
!! | ||
!! Initialise Response from dictionary | ||
!! | ||
!! See tallyResponse_inter for details | ||
!! | ||
subroutine init(self, dict) | ||
class(densityResponse), intent(inout) :: self | ||
class(dictionary), intent(in) :: dict | ||
|
||
! Do nothing | ||
|
||
end subroutine init | ||
|
||
!! | ||
!! Returns the inverse of the particle velocity (response to score particle density) | ||
!! | ||
!! See tallyResponse_inter for details | ||
!! | ||
function get(self, p, xsData) result(val) | ||
class(densityResponse), intent(in) :: self | ||
class(particle), intent(in) :: p | ||
class(nuclearDatabase), intent(inout) :: xsData | ||
real(defReal) :: val | ||
|
||
! Gets the particle velocity from the particle | ||
val = ONE / p % getVelocity() | ||
|
||
end function get | ||
|
||
!! | ||
!! Return to uninitialised State | ||
!! | ||
elemental subroutine kill(self) | ||
class(densityResponse), intent(inout) :: self | ||
|
||
! Do nothing for nothing can be done | ||
|
||
end subroutine kill | ||
|
||
end module densityResponse_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters