Skip to content

Commit

Permalink
another update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcdegraef committed Dec 22, 2024
1 parent 761984b commit 9327a3d
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 130 deletions.
2 changes: 2 additions & 0 deletions NamelistTemplates/EMHREBSDDIC.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
nby = 0,
! maximum number of iterations of the refinement algorithm
maxnumit = 50,
! minimum delta-p value at which the iteration ends
mindeltap = 0.001D0,
! number of threads (default = 1)
nthreads = 1,
!
Expand Down
30 changes: 10 additions & 20 deletions Source/EMsoftOOLib/mod_DIC.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module mod_DIC
real(wp) :: W(3,3) ! shape function
real(wp) :: h(8) ! homography
real(wp) :: CIC ! current value of function to be minimized
integer(ip) :: kx = 4 ! spline order
integer(ip) :: ky = 4 ! spline order
integer(ip) :: kx = 5 ! spline order
integer(ip) :: ky = 5 ! spline order
integer(kind=irg) :: nx ! pattern x-size
integer(kind=irg) :: ny ! pattern y-size
real(wp) :: rnxi ! pattern x scale factor
Expand Down Expand Up @@ -152,7 +152,6 @@ recursive type(DIC_T) function DIC_constructor( nx, ny ) result(DIC)
integer(kind=irg), INTENT(IN) :: ny

integer(kind=irg) :: i, j
real(wp) :: arx, ary

! set pattern dimensions
DIC%nx = nx
Expand All @@ -163,27 +162,14 @@ recursive type(DIC_T) function DIC_constructor( nx, ny ) result(DIC)
DIC%rnxi = 1.0_wp/real(nx-1,wp)
DIC%rnyi = 1.0_wp/real(ny-1,wp)

! account for pattern aspect ratio
arx = 1.0_wp
ary = 1.0_wp
! if (nx.ne.ny) then
! if (nx.lt.ny) then
! arx = DIC%rnyi / DIC%rnxi
! else
! ary = DIC%rnxi / DIC%rnyi
! end if
! end if

do i=0,nx-1
DIC%x(i) = real(i,wp)
end do
DIC%x = DIC%x * arx
! DIC%x = DIC%x * DIC%rnxi
DIC%x = DIC%x * DIC%rnxi
do j=0,ny-1
DIC%y(j) = real(j,wp)
end do
DIC%y = DIC%y * ary
! DIC%y = DIC%y * DIC%rnyi
DIC%y = DIC%y * DIC%rnyi

end function DIC_constructor

Expand Down Expand Up @@ -376,6 +362,7 @@ recursive subroutine getbsplines_(self, verify, refp, defp, grads)
if (refp.eqv..TRUE.) then
! initialize the bsplines for the reference pattern
call self%sref%initialize(self%x,self%y,self%refpat,self%kx,self%ky,iflag)
write (*,*) ' getbsplines_ : ', iflag, minval(self%x), maxval(self%x)
! for potential later calls, allow for extrapolation
call self%sref%set_extrap_flag(.TRUE.)
if (self%verbose) call Message%printMessage(' getbsplines_::b-splines for reference pattern completed')
Expand All @@ -394,6 +381,7 @@ recursive subroutine getbsplines_(self, verify, refp, defp, grads)

if (present(verify)) then
if (verify.eqv..TRUE.) then
errmax = -1.0_wp
do i=0,self%nx-1
do j=0,self%ny-1
! determine how well the spline coefficients represent the original reference pattern
Expand Down Expand Up @@ -473,8 +461,10 @@ recursive subroutine defineSR_(self, nbx, nby, PCx, PCy)

! define the coordinate arrays for the sub-region
allocate( self%xiX(0:self%nxSR-1), self%xiY(0:self%nySR-1) )
self%xiX = self%x(nbx:self%nx-nbx-1) - self%nxSR/2 ! PCx
self%xiY = self%y(nby:self%ny-nby-1) - self%nySR/2 ! PCy
self%xiX = self%x(nbx:self%nx-nbx-1) - PCx ! self%nxSR/2 ! PCx
self%xiY = self%y(nby:self%ny-nby-1) - PCy ! self%nySR/2 ! PCy
write (*,*) 'defineSR : ',minval(self%xiX), maxval(self%xiX)
write (*,*) 'defineSR : ',minval(self%xiY), maxval(self%xiY)
if (self%verbose) call Message%printMessage(' defineSR_::xiX, xiY arrays allocated')

! allocate array for the product of the gradient and the Jacobian
Expand Down
23 changes: 11 additions & 12 deletions Source/EMsoftOOLib/program_mods/mod_HREBSDDIC.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module mod_HREBSDDIC
real(kind=sgl) :: C44
real(kind=sgl) :: C13
real(kind=sgl) :: C33
real(kind=dbl) :: mindeltap
character(fnlen) :: patternfile
character(fnlen) :: DIfile
character(fnlen) :: datafile
Expand Down Expand Up @@ -175,14 +176,15 @@ subroutine readNameList_(self, nmlfile, initonly)
real(kind=sgl) :: C44
real(kind=sgl) :: C13
real(kind=sgl) :: C33
real(kind=dbl) :: mindeltap
character(fnlen) :: patternfile
character(fnlen) :: DIfile
character(fnlen) :: datafile
character(fnlen) :: ppEBSDnml
character(fnlen) :: DInml
character(3) :: crystal

namelist / HREBSDDICdata / patx, paty, nthreads, C11, C12, C44, C13, C33, DIfile, DInml, &
namelist / HREBSDDICdata / patx, paty, nthreads, C11, C12, C44, C13, C33, DIfile, DInml, mindeltap, &
datafile, patternfile, DIfile, ppEBSDnml, crystal, nbx, nby, maxnumit

patx = 0
Expand All @@ -196,6 +198,7 @@ subroutine readNameList_(self, nmlfile, initonly)
C44 = 132.0
C13 = 0.0
C33 = 0.0
mindeltap = 0.001D0
patternfile = 'undefined'
datafile = 'undefined'
DIfile = 'undefined'
Expand Down Expand Up @@ -247,6 +250,7 @@ subroutine readNameList_(self, nmlfile, initonly)
self%nml%C44 = C44
self%nml%C13 = C13
self%nml%C33 = C33
self%nml%mindeltap = mindeltap
self%nml%patternfile = patternfile
self%nml%DIfile = DIfile
self%nml%datafile = datafile
Expand Down Expand Up @@ -295,7 +299,7 @@ recursive subroutine writeHDFNameList_(self, HDF, HDFnames)
type(HDF_T), INTENT(INOUT) :: HDF
type(HDFnames_T), INTENT(INOUT) :: HDFnames

integer(kind=irg),parameter :: n_int = 6, n_real = 5
integer(kind=irg),parameter :: n_int = 6, n_real = 6
integer(kind=irg) :: hdferr, io_int(n_int)
real(kind=sgl) :: io_real(n_real)
character(20) :: intlist(n_int), reallist(n_real)
Expand All @@ -318,12 +322,13 @@ recursive subroutine writeHDFNameList_(self, HDF, HDFnames)
call HDF%writeNMLintegers(io_int, intlist, n_int)

! write all the single reals
io_real = (/ enl%C11, enl%C12, enl%C44, enl%C13, enl%C33 /)
io_real = (/ enl%C11, enl%C12, enl%C44, enl%C13, enl%C33, real(enl%mindeltap) /)
reallist(1) = 'C11'
reallist(2) = 'C12'
reallist(3) = 'C44'
reallist(4) = 'C13'
reallist(5) = 'C33'
reallist(6) = 'mindeltap'
call HDF%writeNMLreals(io_real, reallist, n_real)

! write all the strings
Expand Down Expand Up @@ -542,8 +547,8 @@ subroutine HREBSD_DIC_(self, EMsoft, progname, HDFnames)

!copy the exptpattern into the thread's DIC class
DIC = DIC_T( binx, biny )
call DIC%setverbose( .FALSE. )
! call DIC%setverbose( .TRUE. )
! call DIC%setverbose( .FALSE. )
call DIC%setverbose( .TRUE. )
call DIC%setpattern( 'r', dble(exptpattern) )

! define the border widths nbx and nby for the subregion
Expand Down Expand Up @@ -601,13 +606,7 @@ subroutine HREBSD_DIC_(self, EMsoft, progname, HDFnames)
W = matmul( W, Winv )
W = W / W(3,3)
hg = DIC%getHomography(W)
if (ndp.lt.0.001D0) then
! oldnorm = ndp
! oldW = W
! hg = DIC%getHomography(W)
! else
! W = oldW
! ndp = oldnorm
if (ndp.lt.enl%mindeltap) then
EXIT
end if
end do
Expand Down
8 changes: 8 additions & 0 deletions Source/TestPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ if(EMsoftOO_ENABLE_HDF5_SUPPORT)
INCLUDE_DIRS ${EMsoftOOLib_BINARY_DIR} ${BSPLINEFORTRAN_DIR}
)

Add_EMSoftOO_Executable(TARGET play2
SOURCES ${APP_DIR}/play2.f90
LINK_LIBRARIES ${EXE_LINK_LIBRARIES}
SOLUTION_FOLDER EMsoftOOPublic/TestPrograms
INSTALL_PROGRAM TRUE
INCLUDE_DIRS ${EMsoftOOLib_BINARY_DIR} ${BSPLINEFORTRAN_DIR}
)

Add_EMSoftOO_Executable(TARGET colortest
SOURCES ${APP_DIR}/colortest.f90
LINK_LIBRARIES EMsoftOOLib ${EMSOFTOO_hdf5LinkLibs}
Expand Down
Loading

0 comments on commit 9327a3d

Please sign in to comment.