Merge branch 'test-polynomials' into 'development'
add polynomials to DAMASK_test See merge request damask/DAMASK!827
This commit is contained in:
commit
9cf37c4939
|
@ -94,7 +94,7 @@ unittest_GNU_DEBUG:
|
||||||
- cmake --build ${TMPDIR} --target install
|
- cmake --build ${TMPDIR} --target install
|
||||||
- cd ${TMPDIR}
|
- cd ${TMPDIR}
|
||||||
- ./bin/DAMASK_test
|
- ./bin/DAMASK_test
|
||||||
- find -name \*.gcda | xargs gcov
|
- find -name \*.gcda -not -path "**/test/*" | xargs gcov
|
||||||
|
|
||||||
unittest_GNU_RELEASE:
|
unittest_GNU_RELEASE:
|
||||||
stage: compile
|
stage: compile
|
||||||
|
@ -105,7 +105,7 @@ unittest_GNU_RELEASE:
|
||||||
- cmake --build ${TMPDIR} --target install
|
- cmake --build ${TMPDIR} --target install
|
||||||
- cd ${TMPDIR}
|
- cd ${TMPDIR}
|
||||||
- ./bin/DAMASK_test
|
- ./bin/DAMASK_test
|
||||||
- find -name \*.gcda | xargs gcov
|
- find -name \*.gcda -not -path "**/test/*" | xargs gcov
|
||||||
|
|
||||||
unittest_GNU_PERFORMANCE:
|
unittest_GNU_PERFORMANCE:
|
||||||
stage: compile
|
stage: compile
|
||||||
|
@ -116,7 +116,7 @@ unittest_GNU_PERFORMANCE:
|
||||||
- cmake --build ${TMPDIR} --target install
|
- cmake --build ${TMPDIR} --target install
|
||||||
- cd ${TMPDIR}
|
- cd ${TMPDIR}
|
||||||
- ./bin/DAMASK_test
|
- ./bin/DAMASK_test
|
||||||
- find -name \*.gcda | xargs gcov
|
- find -name \*.gcda -not -path "**/test/*" | xargs gcov
|
||||||
|
|
||||||
|
|
||||||
grid_GNU:
|
grid_GNU:
|
||||||
|
|
|
@ -25,7 +25,8 @@ module polynomials
|
||||||
|
|
||||||
public :: &
|
public :: &
|
||||||
polynomial, &
|
polynomial, &
|
||||||
polynomials_init
|
polynomials_init, &
|
||||||
|
polynomials_selfTest
|
||||||
|
|
||||||
contains
|
contains
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ subroutine polynomials_init()
|
||||||
|
|
||||||
print'(/,1x,a)', '<<<+- polynomials init -+>>>'; flush(IO_STDOUT)
|
print'(/,1x,a)', '<<<+- polynomials init -+>>>'; flush(IO_STDOUT)
|
||||||
|
|
||||||
call selfTest()
|
call polynomials_selfTest()
|
||||||
|
|
||||||
end subroutine polynomials_init
|
end subroutine polynomials_init
|
||||||
|
|
||||||
|
@ -68,26 +69,24 @@ function polynomial_from_dict(dict,y,x) result(p)
|
||||||
type(tPolynomial) :: p
|
type(tPolynomial) :: p
|
||||||
|
|
||||||
real(pREAL), dimension(:), allocatable :: coef
|
real(pREAL), dimension(:), allocatable :: coef
|
||||||
real(pREAL) :: x_ref
|
|
||||||
integer :: i, o
|
integer :: i, o
|
||||||
character(len=1) :: o_s
|
character :: o_s
|
||||||
|
|
||||||
|
|
||||||
allocate(coef(1),source=dict%get_asReal(y))
|
allocate(coef(1),source=dict%get_asReal(y))
|
||||||
|
|
||||||
if (dict%contains(y//','//x)) then
|
if (dict%contains(y//','//x)) coef = [coef,dict%get_asReal(y//','//x)]
|
||||||
x_ref = dict%get_asReal(x//'_ref')
|
|
||||||
coef = [coef,dict%get_asReal(y//','//x)]
|
|
||||||
end if
|
|
||||||
do o = 2,4
|
do o = 2,4
|
||||||
write(o_s,'(I0.0)') o
|
write(o_s,'(I0.0)') o
|
||||||
if (dict%contains(y//','//x//'^'//o_s)) then
|
if (dict%contains(y//','//x//'^'//o_s)) &
|
||||||
x_ref = dict%get_asReal(x//'_ref')
|
|
||||||
coef = [coef,[(0.0_pREAL,i=size(coef),o-1)],dict%get_asReal(y//','//x//'^'//o_s)]
|
coef = [coef,[(0.0_pREAL,i=size(coef),o-1)],dict%get_asReal(y//','//x//'^'//o_s)]
|
||||||
end if
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
p = Polynomial(coef,x_ref)
|
if (size(coef) > 1) then
|
||||||
|
p = polynomial(coef,dict%get_asReal(x//'_ref'))
|
||||||
|
else
|
||||||
|
p = polynomial(coef,-huge(1.0_pREAL))
|
||||||
|
end if
|
||||||
|
|
||||||
end function polynomial_from_dict
|
end function polynomial_from_dict
|
||||||
|
|
||||||
|
@ -105,8 +104,8 @@ pure function eval(self,x) result(y)
|
||||||
integer :: o
|
integer :: o
|
||||||
|
|
||||||
|
|
||||||
y = 0.0_pREAL
|
y = self%coef(ubound(self%coef,1))
|
||||||
do o = ubound(self%coef,1), 0, -1
|
do o = ubound(self%coef,1)-1, 0, -1
|
||||||
y = y*(x-self%x_ref) + self%coef(o)
|
y = y*(x-self%x_ref) + self%coef(o)
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
@ -116,7 +115,7 @@ end function eval
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Check correctness of polynomical functionality.
|
!> @brief Check correctness of polynomical functionality.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine selfTest()
|
subroutine polynomials_selfTest()
|
||||||
|
|
||||||
type(tPolynomial) :: p1, p2
|
type(tPolynomial) :: p1, p2
|
||||||
real(pREAL), dimension(5) :: coef
|
real(pREAL), dimension(5) :: coef
|
||||||
|
@ -131,9 +130,9 @@ subroutine selfTest()
|
||||||
call random_number(x_ref)
|
call random_number(x_ref)
|
||||||
call random_number(x)
|
call random_number(x)
|
||||||
|
|
||||||
coef = coef*10_pREAL -0.5_pREAL
|
coef = 10_pREAL*(coef-0.5_pREAL)
|
||||||
x_ref = x_ref*10_pREAL -0.5_pREAL
|
x_ref = 10_pREAL*(x_ref-0.5_pREAL)
|
||||||
x = x*10_pREAL -0.5_pREAL
|
x = 10_pREAL*(x-0.5_pREAL)
|
||||||
|
|
||||||
p1 = polynomial([coef(1)],x_ref)
|
p1 = polynomial([coef(1)],x_ref)
|
||||||
if (dNeq(p1%at(x),coef(1))) error stop 'polynomial: eval(constant)'
|
if (dNeq(p1%at(x),coef(1))) error stop 'polynomial: eval(constant)'
|
||||||
|
@ -155,7 +154,11 @@ subroutine selfTest()
|
||||||
dict => YAML_parse_str_asDict(trim(YAML_s))
|
dict => YAML_parse_str_asDict(trim(YAML_s))
|
||||||
p2 = polynomial(dict,'C','T')
|
p2 = polynomial(dict,'C','T')
|
||||||
if (dNeq(p1%at(x),p2%at(x),1.0e-6_pREAL)) error stop 'polynomials: init'
|
if (dNeq(p1%at(x),p2%at(x),1.0e-6_pREAL)) error stop 'polynomials: init'
|
||||||
y = coef(1)+coef(2)*(x-x_ref)+coef(3)*(x-x_ref)**2+coef(4)*(x-x_ref)**3+coef(5)*(x-x_ref)**4
|
y = coef(1)*(x-x_ref)**0 &
|
||||||
|
+ coef(2)*(x-x_ref)**1 &
|
||||||
|
+ coef(3)*(x-x_ref)**2 &
|
||||||
|
+ coef(4)*(x-x_ref)**3 &
|
||||||
|
+ coef(5)*(x-x_ref)**4
|
||||||
if (dNeq(p1%at(x),y,1.0e-6_pREAL)) error stop 'polynomials: eval(full)'
|
if (dNeq(p1%at(x),y,1.0e-6_pREAL)) error stop 'polynomials: eval(full)'
|
||||||
|
|
||||||
YAML_s = 'C: 0.0'//IO_EOL//&
|
YAML_s = 'C: 0.0'//IO_EOL//&
|
||||||
|
@ -187,6 +190,6 @@ subroutine selfTest()
|
||||||
if (dNeq(p1%at(x_ref+x),p1%at(x_ref-x),1.0e-6_pREAL)) error stop 'polynomials: eval(quartic)'
|
if (dNeq(p1%at(x_ref+x),p1%at(x_ref-x),1.0e-6_pREAL)) error stop 'polynomials: eval(quartic)'
|
||||||
|
|
||||||
|
|
||||||
end subroutine selfTest
|
end subroutine polynomials_selfTest
|
||||||
|
|
||||||
end module polynomials
|
end module polynomials
|
||||||
|
|
|
@ -7,6 +7,7 @@ program DAMASK_test
|
||||||
use test_prec
|
use test_prec
|
||||||
use test_misc
|
use test_misc
|
||||||
use test_math
|
use test_math
|
||||||
|
use test_polynomials
|
||||||
use test_tables
|
use test_tables
|
||||||
use test_crystal
|
use test_crystal
|
||||||
use test_rotations
|
use test_rotations
|
||||||
|
@ -36,6 +37,10 @@ program DAMASK_test
|
||||||
call test_math_run()
|
call test_math_run()
|
||||||
write(IO_STDOUT,fmt='(a)') ok
|
write(IO_STDOUT,fmt='(a)') ok
|
||||||
|
|
||||||
|
write(IO_STDOUT,fmt=fmt, advance='no') 'polynomials','...'
|
||||||
|
call test_polynomials_run()
|
||||||
|
write(IO_STDOUT,fmt='(a)') ok
|
||||||
|
|
||||||
write(IO_STDOUT,fmt=fmt, advance='no') 'tables','...'
|
write(IO_STDOUT,fmt=fmt, advance='no') 'tables','...'
|
||||||
call test_tables_run()
|
call test_tables_run()
|
||||||
write(IO_STDOUT,fmt='(a)') ok
|
write(IO_STDOUT,fmt='(a)') ok
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
module test_polynomials
|
||||||
|
use polynomials
|
||||||
|
|
||||||
|
implicit none(type,external)
|
||||||
|
|
||||||
|
private
|
||||||
|
public :: test_polynomials_run
|
||||||
|
|
||||||
|
contains
|
||||||
|
|
||||||
|
subroutine test_polynomials_run()
|
||||||
|
|
||||||
|
call polynomials_selfTest()
|
||||||
|
|
||||||
|
end subroutine test_polynomials_run
|
||||||
|
|
||||||
|
end module test_polynomials
|
Loading…
Reference in New Issue