Commit 0ecbd33b authored by Graham, Aaron's avatar Graham, Aaron
Browse files

Reworks ElementsIsotopes Module

Eliminates the class in favor of standalone procedures and fixes issues with upper/lower case

This supports VERA Issue https://code.ornl.gov/vera/vera-dev/-/issues/5018
parent c606266a
This diff is collapsed.
......@@ -444,7 +444,6 @@ ENDSUBROUTINE clearSubCompEnvs
SUBROUTINE addExceptionHandlerSurrogates(ce)
USE Allocs, ONLY : eAllocs
USE EigenvalueSolverTypes, ONLY : eEigenvalueSolverType
USE ElementsIsotopes, ONLY : eElementsIsotopes
USE ExpTables, ONLY : eExpTable
USE FMU_Wrapper, ONLY : eFMU_Wrapper
USE IAPWSWaterPropertiesModule, ONLY : eWaterProp
......@@ -464,7 +463,6 @@ SUBROUTINE addExceptionHandlerSurrogates(ce)
CALL eAllocs%addSurrogate(ce)
CALL eEigenvalueSolverType%addSurrogate(ce)
CALL eElementsIsotopes%addSurrogate(ce)
CALL eMeshTransfer%addSurrogate(ce)
CALL eExpTable%addSurrogate(ce)
CALL eFMU_Wrapper%addSurrogate(ce)
......
......@@ -41,9 +41,7 @@ FUNCTION SpeciesElements_getElementArray(formula) RESULT(eleArray)
REAL(SRK) :: coeff
CHARACTER(LEN=1) :: letter, nextLetter
CHARACTER(LEN=2) :: element
TYPE(ElementsIsotopesType) :: myEI
CALL myEI%init()
eleArray = 0.0
DO i=1, LEN(formula)
......@@ -72,7 +70,7 @@ FUNCTION SpeciesElements_getElementArray(formula) RESULT(eleArray)
coeff = letter
END IF
! Gets the atomic number
Z = myEI%getAtomicNumber(element)
Z = getAtomicNumber(element)
! Sets the coeff in the array
eleArray(Z) = coeff
END DO
......
......@@ -11,15 +11,13 @@ PROGRAM testElementsIsotopes
USE ISO_FORTRAN_ENV
USE UnitTest
USE IntrType
USE Strings
USE ElementsIsotopes
IMPLICIT NONE
TYPE(ElementsIsotopesType) :: myEI
CREATE_TEST("ElementsIsotopes")
REGISTER_SUBTEST('Initialize',testInit)
REGISTER_SUBTEST('isValidIsoName',testIsValidIsoName)
REGISTER_SUBTEST('isValidElemName',testIsValidElemName)
REGISTER_SUBTEST('getZAID',testGetZAID)
......@@ -28,7 +26,6 @@ REGISTER_SUBTEST('getElementName',testGetElementName)
REGISTER_SUBTEST('getAtomicNumber',testGetAtomicNumber)
REGISTER_SUBTEST('getMassNumber',testGetMassNumber)
REGISTER_SUBTEST('isMetastable',testisMetastable)
REGISTER_SUBTEST('Clear',testClear)
REGISTER_SUBTEST('getDecayType_ZAID',testGetDecayType_ZAID)
......@@ -79,104 +76,90 @@ SUBROUTINE testGetDecayType_ZAID()
ENDSUBROUTINE testGetDecayType_ZAID
!
!-------------------------------------------------------------------------------
SUBROUTINE testInit()
CALL myEI%init()
ASSERT(myEI%isInit,'isInit')
ENDSUBROUTINE testInit
!
!-------------------------------------------------------------------------------
SUBROUTINE testClear()
CALL myEI%clear()
ASSERT(.NOT. myEI%isInit,'isInit')
ENDSUBROUTINE testClear
!
!-------------------------------------------------------------------------------
SUBROUTINE testIsValidIsoName()
ASSERT(myEI%isValidIsoName('H-2'),'H-2')
ASSERT(myEI%isValidIsoName(' H-2'),' H-2')
ASSERT(myEI%isValidIsoName('AG-110m'),'AG-110m')
ASSERT(myEI%isValidIsoName('f-18m'),'f-18m')
ASSERT(myEI%isValidIsoName(' f-18m'),' f-18m')
ASSERT(myEI%isValidIsoName('B-NAT'),'B-NAT')
ASSERT(.NOT. myEI%isValidIsoName('BadName'),'Bad Name')
ASSERT(.NOT. myEI%isValidIsoName('H2'),'Missing Hyphen')
ASSERT(.NOT. myEI%isValidIsoName('-H2'),'Wrong Hyphen')
ASSERT(.NOT. myEI%isValidIsoName('ZZ-42'),'Bad Element')
ASSERT(.NOT. myEI%isValidIsoName('B-EN'),'Bad Mass Number')
ASSERT(isValidIsoName('H-2'),'H-2')
ASSERT(isValidIsoName(' H-2'),' H-2')
ASSERT(isValidIsoName('AG-110m'),'AG-110m')
ASSERT(isValidIsoName('f-18m'),'f-18m')
ASSERT(isValidIsoName(' f-18m'),' f-18m')
ASSERT(isValidIsoName('B-NAT'),'B-NAT')
ASSERT(.NOT. isValidIsoName('BadName'),'Bad Name')
ASSERT(.NOT. isValidIsoName('H2'),'Missing Hyphen')
ASSERT(.NOT. isValidIsoName('-H2'),'Wrong Hyphen')
ASSERT(.NOT. isValidIsoName('ZZ-42'),'Bad Element')
ASSERT(.NOT. isValidIsoName('B-EN'),'Bad Mass Number')
ENDSUBROUTINE testIsValidIsoName
!
!-------------------------------------------------------------------------------
SUBROUTINE testIsValidElemName()
ASSERT(myEI%isValidElemName('H'),'H')
ASSERT(myEI%isValidElemName(' H'),' H')
ASSERT(myEI%isValidElemName(' H '),' H ')
ASSERT(myEI%isValidElemName('H '),'H ')
ASSERT(myEI%isValidElemName('He'),'He')
ASSERT(myEI%isValidElemName(' He'),' He')
ASSERT(myEI%isValidElemName(' He '),' He ')
ASSERT(myEI%isValidElemName('He '),'He ')
ASSERT(.NOT.myEI%isValidElemName('Z'),'Bad Name')
ASSERT(.NOT.myEI%isValidElemName('Z-12'),'Isotope, not element')
ASSERT(isValidElemName('H'),'H')
ASSERT(isValidElemName(' H'),' H')
ASSERT(isValidElemName(' H '),' H ')
ASSERT(isValidElemName('H '),'H ')
ASSERT(isValidElemName('He'),'He')
ASSERT(isValidElemName(' He'),' He')
ASSERT(isValidElemName(' He '),' He ')
ASSERT(isValidElemName('He '),'He ')
ASSERT(.NOT.isValidElemName('Z'),'Bad Name')
ASSERT(.NOT.isValidElemName('Z-12'),'Isotope, not element')
ENDSUBROUTINE testIsValidElemName
!
!-------------------------------------------------------------------------------
SUBROUTINE testGetZAID()
ASSERT_EQ(myEI%getZAID('H-2'),1002,'H-2')
ASSERT_EQ(myEI%getZAID(' H-2'),1002,' H-2')
ASSERT_EQ(myEI%getZAID('AG-110m'),47110,'AG-110m')
ASSERT_EQ(myEI%getZAID('f-18m'),9018,'f-18m')
ASSERT_EQ(myEI%getZAID(' f-18m'),9018,' f-18m')
ASSERT_EQ(myEI%getZAID('B-NAT'),5000,'B-NAT')
ASSERT_EQ(getZAID('H-2'),1002,'H-2')
ASSERT_EQ(getZAID(' H-2'),1002,' H-2')
ASSERT_EQ(getZAID('AG-110m'),47110,'AG-110m')
ASSERT_EQ(getZAID('f-18m'),9018,'f-18m')
ASSERT_EQ(getZAID(' f-18m'),9018,' f-18m')
ASSERT_EQ(getZAID('B-NAT'),5000,'B-NAT')
ENDSUBROUTINE testGetZAID
!
!-------------------------------------------------------------------------------
SUBROUTINE testGetIsotopeName()
ASSERT_EQ(myEI%getIsoName(1002),'H-2','1002')
ASSERT_EQ(myEI%getIsoName(47710),'AG-710','47710')
ASSERT_EQ(myEI%getIsoName(5000),'B-NAT','5000')
ASSERT_EQ(getIsoName(1002),'H-2','1002')
ASSERT_EQ(getIsoName(47710),'Ag-710','47710')
ASSERT_EQ(getIsoName(5000),'B-NAT','5000')
ENDSUBROUTINE testGetIsotopeName
!
!-------------------------------------------------------------------------------
SUBROUTINE testGetElementName()
ASSERT_EQ(myEI%getElementName(1002),'H','1002')
ASSERT_EQ(myEI%getElementName(47710),'AG','47710')
ASSERT_EQ(getElementName(1002),'H','1002')
ASSERT_EQ(getElementName(47710),'Ag','47710')
ASSERT_EQ(myEI%getElementName(1),'H','1')
ASSERT_EQ(myEI%getElementName(47),'AG','47')
ASSERT_EQ(getElementName(1),'H','1')
ASSERT_EQ(getElementName(47),'Ag','47')
ASSERT_EQ(myEI%getElementName('U-235'),'U','U-235')
ASSERT_EQ(myEI%getElementName('xe-135m'),'XE','xe-135m')
ASSERT_EQ(getElementName('U-235'),'U','U-235')
ASSERT_EQ(getElementName('xe-135m'),'Xe','xe-135m')
ENDSUBROUTINE testGetElementName
!
!-------------------------------------------------------------------------------
SUBROUTINE testGetAtomicNumber()
ASSERT_EQ(myEI%getAtomicNumber(1002),1,'1002')
ASSERT_EQ(myEI%getAtomicNumber(47710),47,'47710')
ASSERT_EQ(getAtomicNumber(1002),1,'1002')
ASSERT_EQ(getAtomicNumber(47710),47,'47710')
ASSERT_EQ(myEI%getAtomicNumber('U '),92,'U')
ASSERT_EQ(myEI%getAtomicNumber('pu'),94,'pu')
ASSERT_EQ(getAtomicNumber('U '),92,'U')
ASSERT_EQ(getAtomicNumber('pu'),94,'pu')
ASSERT_EQ(myEI%getAtomicNumber('U-235'),92,'U-235')
ASSERT_EQ(myEI%getAtomicNumber('F-18m'),9,'F-18m')
ASSERT_EQ(getAtomicNumber('U-235'),92,'U-235')
ASSERT_EQ(getAtomicNumber('F-18m'),9,'F-18m')
ENDSUBROUTINE testGetAtomicNumber
!
!-------------------------------------------------------------------------------
SUBROUTINE testGetMassNumber()
ASSERT_EQ(myEI%getMassNumber(1002),2,'1002')
ASSERT_EQ(myEI%getMassNumber(47710),710,'47710')
ASSERT_EQ(getMassNumber(1002),2,'1002')
ASSERT_EQ(getMassNumber(47710),710,'47710')
ASSERT_EQ(myEI%getMassNumber('U-235'),235,'U-235')
ASSERT_EQ(myEI%getMassNumber('F-18m'),18,'F-18m')
ASSERT_EQ(getMassNumber('U-235'),235,'U-235')
ASSERT_EQ(getMassNumber('F-18m'),18,'F-18m')
ENDSUBROUTINE testGetMassNumber
!
!-------------------------------------------------------------------------------
SUBROUTINE testisMetastable()
ASSERT(.NOT. myEI%isMetastable('U-235'),'U-235')
ASSERT(myEI%isMetastable('Am-242m'),'Am-242m')
ASSERT(myEI%isMetastable('Am-242M'),'Am-242M')
ASSERT(myEI%isMetastable('f-18m'),'f-18m')
ASSERT(.NOT. isMetastable('U-235'),'U-235')
ASSERT(isMetastable('Am-242m'),'Am-242m')
ASSERT(isMetastable('Am-242M'),'Am-242M')
ASSERT(isMetastable('f-18m'),'f-18m')
ENDSUBROUTINE testisMetastable
!
ENDPROGRAM testElementsIsotopes
......@@ -16,8 +16,6 @@ USE ElementsIsotopes
IMPLICIT NONE
TYPE(ElementsIsotopesType) :: myEI
CREATE_TEST("SpeciesElements")
REGISTER_SUBTEST('Test Species to Element array',testSpeciesElementsBase)
......@@ -33,38 +31,36 @@ SUBROUTINE testSpeciesElementsBase()
TYPE(StringType) :: testWord
REAL(SRK), DIMENSION(1:119) :: testArray
CALL myEI%init()
! Test H2O
testWord = 'H2O'
testArray = SpeciesElements_getElementArray(testWord)
ASSERT_EQ(testArray(myEI%getAtomicNumber('H')),2.0,'H2')
ASSERT_EQ(testArray(myEI%getAtomicNumber('O')),1.0,'O')
ASSERT_EQ(testArray(getAtomicNumber('H')),2.0,'H2')
ASSERT_EQ(testArray(getAtomicNumber('O')),1.0,'O')
! Test C2H6O
testWord = 'C2H6O'
testArray = SpeciesElements_getElementArray(testWord)
ASSERT_EQ(testArray(myEI%getAtomicNumber('C')),2.0,'C2')
ASSERT_EQ(testArray(myEI%getAtomicNumber('H')),6.0,'H6')
ASSERT_EQ(testArray(myEI%getAtomicNumber('O')),1.0,'O')
ASSERT_EQ(testArray(getAtomicNumber('C')),2.0,'C2')
ASSERT_EQ(testArray(getAtomicNumber('H')),6.0,'H6')
ASSERT_EQ(testArray(getAtomicNumber('O')),1.0,'O')
! Test UF4
testWord = 'UF4'
testArray = SpeciesElements_getElementArray(testWord)
ASSERT_EQ(testArray(myEI%getAtomicNumber('U')),1.0,'U')
ASSERT_EQ(testArray(myEI%getAtomicNumber('F')),4.0,'F4')
ASSERT_EQ(testArray(getAtomicNumber('U')),1.0,'U')
ASSERT_EQ(testArray(getAtomicNumber('F')),4.0,'F4')
! Test NaCl
testWord = 'NaCl'
testArray = SpeciesElements_getElementArray(testWord)
ASSERT_EQ(testArray(myEI%getAtomicNumber('Na')),1.0,'Na')
ASSERT_EQ(testArray(myEI%getAtomicNumber('Cl')),1.0,'Cl')
ASSERT_EQ(testArray(getAtomicNumber('Na')),1.0,'Na')
ASSERT_EQ(testArray(getAtomicNumber('Cl')),1.0,'Cl')
! Test PuO2
testWord = 'PuO2'
testArray = SpeciesElements_getElementArray(testWord)
ASSERT_EQ(testArray(myEI%getAtomicNumber('Pu')),1.0,'Pu')
ASSERT_EQ(testArray(myEI%getAtomicNumber('O')),2.0,'O2')
ASSERT_EQ(testArray(getAtomicNumber('Pu')),1.0,'Pu')
ASSERT_EQ(testArray(getAtomicNumber('O')),2.0,'O2')
ENDSUBROUTINE testSpeciesElementsBase
!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment