Skip to content

Commit

Permalink
adds EMgetKAM program
Browse files Browse the repository at this point in the history
orientation averaging needs to be verified.
  • Loading branch information
marcdegraef committed Dec 29, 2024
1 parent 5c71bec commit 3a29cb0
Show file tree
Hide file tree
Showing 8 changed files with 672 additions and 14 deletions.
10 changes: 0 additions & 10 deletions NamelistTemplates/EMKAM.template

This file was deleted.

10 changes: 10 additions & 0 deletions NamelistTemplates/EMgetKAM.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
&getKAM
! min and max values to use for KAM map [degrees]; anything outside this range will be set to zero
kamrange = 0.0, 5.0,
! orientation average (0 for no, integer otherwise; default 0)
orav = 20,
! name of input dot product HDF5 file [relative to EMdatapathname]
dotproductfile = 'undefined',
! name of tiff output file for KAM map [relative to EMdatapathname]
kamtiff = 'undefined',
/
9 changes: 9 additions & 0 deletions Source/DictionaryIndexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ if(EMsoftOO_ENABLE_HDF5_SUPPORT)
INCLUDE_DIRS ${EMsoftOOLib_BINARY_DIR}
)

Add_EMsoftOO_Executable(TARGET EMgetKAM
SOURCES ${APP_DIR}/EMgetKAM.f90
LINK_LIBRARIES ${EXE_LINK_LIBRARIES}
TEMPLATE ${TMPLT_DIR}/EMgetKAM.template
SOLUTION_FOLDER EMsoftOOPublic/DictionaryIndexing
INSTALL_PROGRAM TRUE
INCLUDE_DIRS ${EMsoftOOLib_BINARY_DIR}
)

Add_EMsoftOO_Executable(TARGET EMgetCTF
SOURCES ${APP_DIR}/EMgetCTF.f90
LINK_LIBRARIES ${EXE_LINK_LIBRARIES}
Expand Down
59 changes: 59 additions & 0 deletions Source/DictionaryIndexing/EMgetKAM.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
! ###################################################################
! Copyright (c) 2016-2024, Marc De Graef Research Group/Carnegie Mellon University
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without modification, are
! permitted provided that the following conditions are met:
!
! - Redistributions of source code must retain the above copyright notice, this list
! of conditions and the following disclaimer.
! - Redistributions in binary form must reproduce the above copyright notice, this
! list of conditions and the following disclaimer in the documentation and/or
! other materials provided with the distribution.
! - Neither the names of Marc De Graef, Carnegie Mellon University nor the names
! of its contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! ###################################################################

program EMgetKAM
!! author: MDG
!! version: 1.0
!! date: 01/24/20
!!
!!

use mod_kinds
use mod_global
use mod_EMsoft
use mod_KAM
use stringconstants

IMPLICIT NONE

character(fnlen) :: progname = 'EMgetKAM.f90'
character(fnlen) :: progdesc = 'Program to compute Kernel Average Misorientation maps'

type(EMsoft_T) :: EMsoft
type(KAM_T) :: KAM

! print the EMsoft header and handle any command line arguments
EMsoft = EMsoft_T( progname, progdesc, tpl = (/ 84 /) )

! deal with the namelist stuff
KAM = KAM_T(EMsoft%nmldeffile)

! perform the computations
call KAM%KAM(EMsoft, progname)

end program EMgetKAM
1 change: 1 addition & 0 deletions Source/EMsoftOOLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(EMsoftOOLib_SRCS
${EMsoftOOLib_SOURCE_DIR}/program_mods/mod_SphInx.f90
${EMsoftOOLib_SOURCE_DIR}/program_mods/mod_4DEBSD.f90
${EMsoftOOLib_SOURCE_DIR}/program_mods/mod_ppEBSD.f90
${EMsoftOOLib_SOURCE_DIR}/program_mods/mod_KAM.f90

${EMsoftOOLib_Additional_SRCS}
)
Expand Down
48 changes: 45 additions & 3 deletions Source/EMsoftOOLib/mod_rotations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ module mod_rotations

! we use a private parameter and a pair of get/set methods to control the precision (single or double);
! by default, all rotation operations are performed in double precision
logical :: rotdoubleprecision = .TRUE.
public :: setRotationPrecision, getRotationPrecision, toRadians, toDegrees, cvtoRadians, cvtoDegrees, &
logical :: rotdoubleprecision = .TRUE., checkvalidity = .FALSE.
public :: setRotationPrecision, setCheckValidity, getRotationPrecision, toRadians, toDegrees, cvtoRadians, cvtoDegrees, &
RodriguesProduct, quat_average

interface quat_average
Expand Down Expand Up @@ -2784,6 +2784,8 @@ recursive function r_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
if (self%rd(4).lt.0.D0) then
call Message%printMessage('rotations:r_check: Rodrigues-Frank vector has negative length')
Expand All @@ -2799,6 +2801,7 @@ recursive function r_check_(self) result(res)
self%r(1:3) = self%r(1:3) / r
res = 0
end if
end if

end function r_check_

Expand Down Expand Up @@ -2826,6 +2829,8 @@ recursive function s_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
rd = sqrt(sum(self%sd*self%sd))
if (rd.gt.(1.D0+epsd)) then
Expand All @@ -2839,6 +2844,7 @@ recursive function s_check_(self) result(res)
endif
res = 0
end if
end if

end function s_check_

Expand Down Expand Up @@ -2867,6 +2873,8 @@ recursive function o_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
! compute the determinant (must be +1)
detd = self%od(1,1)*self%od(2,2)*self%od(3,3) + self%od(1,2)*self%od(2,3)*self%od(3,1) + &
Expand Down Expand Up @@ -2904,6 +2912,7 @@ recursive function o_check_(self) result(res)
endif
res = 0
end if
end if

end function o_check_

Expand All @@ -2928,6 +2937,9 @@ recursive function h_check_(self) result(res)
real(kind=dbl) :: rd

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
rd = sqrt(sum(self%hd*self%hd))
if (rd.gt.LPs%R1) then
Expand All @@ -2941,6 +2953,7 @@ recursive function h_check_(self) result(res)
endif
res = 0
end if
end if

end function h_check_

Expand Down Expand Up @@ -2968,6 +2981,8 @@ recursive function a_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
rd = sqrt(sum(self%ad(1:3)*self%ad(1:3)))
if ((self%ad(4).lt.0.D0).or.(self%ad(4).gt.cPi)) then
Expand All @@ -2987,6 +3002,7 @@ recursive function a_check_(self) result(res)
endif
res = 0
end if
end if

end function a_check_

Expand Down Expand Up @@ -3014,6 +3030,9 @@ recursive function v_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then


if (rotdoubleprecision) then
rd = sqrt(sum(self%vd*self%vd))
write (*,*) rd, cPi, rd-cPi
Expand All @@ -3028,6 +3047,7 @@ recursive function v_check_(self) result(res)
endif
res = 0
end if
end if

end function v_check_

Expand All @@ -3053,6 +3073,9 @@ recursive function c_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then


if (rotdoubleprecision) then
rd = maxval(abs(self%cd))
if (rd.gt.LPs%ap/2.D0) then
Expand All @@ -3066,6 +3089,7 @@ recursive function c_check_(self) result(res)
endif
res = 0
end if
end if

end function c_check_

Expand All @@ -3089,6 +3113,9 @@ recursive function e_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then


if (rotdoubleprecision) then
if ((self%ed(1).lt.0.D0).or.(self%ed(1).gt.(2.D0*cPi))) then
call Message%printMessage('rotations:e_check: phi1 Euler angle outside of valid range [0,2pi]')
Expand All @@ -3112,6 +3139,7 @@ recursive function e_check_(self) result(res)
endif
res = 0
end if
end if

end function e_check_

Expand All @@ -3138,6 +3166,8 @@ recursive function q_check_(self) result(res)

res = 1

if (checkvalidity.eqv..TRUE.) then

if (rotdoubleprecision) then
rd = dsqrt(sum(self%qd*self%qd))
self%qd = self%qd/rd
Expand All @@ -3147,7 +3177,7 @@ recursive function q_check_(self) result(res)
self%q = self%q/r
res = 0
end if

end if
end function q_check_

!--------------------------------------------------------------------------
Expand Down Expand Up @@ -6099,6 +6129,18 @@ recursive function qe_(self) result(e)

end function qe_

!------------------------------------------
subroutine setCheckValidity(c)
!DEC$ ATTRIBUTES DLLEXPORT :: setCheckValidity

IMPLICIT NONE

logical, INTENT(IN) :: c

checkvalidity = c

end subroutine setCheckValidity

!------------------------------------------
subroutine setRotationPrecision(c)
!DEC$ ATTRIBUTES DLLEXPORT :: setRotationPrecision
Expand Down
Loading

0 comments on commit 3a29cb0

Please sign in to comment.