138 lines
4.2 KiB
Fortran
138 lines
4.2 KiB
Fortran
module fem_modal_analysis
|
|
use fem_precision
|
|
use fem_error
|
|
implicit none
|
|
|
|
private
|
|
|
|
public :: modal_filter_range
|
|
public :: modal_assurance
|
|
public :: modal_orthogonality
|
|
public :: modal_effective_mass
|
|
|
|
contains
|
|
|
|
subroutine modal_filter_range(num_values, values, lower, upper, max_count, &
|
|
indices, count, ierr)
|
|
integer, intent(in) :: num_values
|
|
real(rk), intent(in) :: values(num_values)
|
|
real(rk), intent(in) :: lower
|
|
real(rk), intent(in) :: upper
|
|
integer, intent(in) :: max_count
|
|
integer, intent(out) :: indices(max_count)
|
|
integer, intent(out) :: count
|
|
integer, intent(out) :: ierr
|
|
integer :: i
|
|
|
|
if (num_values .le. 0 .or. max_count .le. 0 .or. upper .lt. lower) then
|
|
call error_set(FEM_ERR_SOLVER, 'invalid modal filter range input', ierr)
|
|
return
|
|
end if
|
|
|
|
indices = 0
|
|
count = 0
|
|
do i = 1, num_values
|
|
if (values(i) .ge. lower .and. values(i) .le. upper) then
|
|
count = count + 1
|
|
if (count .gt. max_count) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal filter output is too small', ierr)
|
|
return
|
|
end if
|
|
indices(count) = i
|
|
end if
|
|
end do
|
|
ierr = FEM_SUCCESS
|
|
end subroutine modal_filter_range
|
|
|
|
subroutine modal_assurance(n, mode_a, mode_b, mac, ierr)
|
|
integer, intent(in) :: n
|
|
real(rk), intent(in) :: mode_a(n)
|
|
real(rk), intent(in) :: mode_b(n)
|
|
real(rk), intent(out) :: mac
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: aa
|
|
real(rk) :: bb
|
|
real(rk) :: ab
|
|
|
|
if (n .le. 0) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal assurance size is invalid', ierr)
|
|
return
|
|
end if
|
|
aa = dot_product(mode_a, mode_a)
|
|
bb = dot_product(mode_b, mode_b)
|
|
if (aa .le. tiny(ONE) .or. bb .le. tiny(ONE)) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal assurance vector is zero', ierr)
|
|
return
|
|
end if
|
|
ab = dot_product(mode_a, mode_b)
|
|
mac = ab * ab / (aa * bb)
|
|
ierr = FEM_SUCCESS
|
|
end subroutine modal_assurance
|
|
|
|
subroutine modal_orthogonality(n, bmat, num_modes, modes, max_offdiag, &
|
|
max_diag_error, ierr)
|
|
integer, intent(in) :: n
|
|
real(rk), intent(in) :: bmat(n,n)
|
|
integer, intent(in) :: num_modes
|
|
real(rk), intent(in) :: modes(n,num_modes)
|
|
real(rk), intent(out) :: max_offdiag
|
|
real(rk), intent(out) :: max_diag_error
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: gram(num_modes,num_modes)
|
|
integer :: i
|
|
integer :: j
|
|
|
|
if (n .le. 0 .or. num_modes .le. 0) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal orthogonality dimensions are invalid', ierr)
|
|
return
|
|
end if
|
|
|
|
gram = matmul(transpose(modes), matmul(bmat, modes))
|
|
max_offdiag = ZERO
|
|
max_diag_error = ZERO
|
|
do i = 1, num_modes
|
|
max_diag_error = max(max_diag_error, abs(gram(i,i) - ONE))
|
|
do j = i + 1, num_modes
|
|
max_offdiag = max(max_offdiag, abs(gram(i,j)))
|
|
end do
|
|
end do
|
|
ierr = FEM_SUCCESS
|
|
end subroutine modal_orthogonality
|
|
|
|
subroutine modal_effective_mass(n, bmat, mode, influence, eff_mass, &
|
|
participation, ierr)
|
|
integer, intent(in) :: n
|
|
real(rk), intent(in) :: bmat(n,n)
|
|
real(rk), intent(in) :: mode(n)
|
|
real(rk), intent(in) :: influence(n)
|
|
real(rk), intent(out) :: eff_mass
|
|
real(rk), intent(out) :: participation
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: bmode(n)
|
|
real(rk) :: binfl(n)
|
|
real(rk) :: modal_mass
|
|
real(rk) :: total_mass
|
|
real(rk) :: numerator
|
|
|
|
if (n .le. 0) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal effective mass size is invalid', ierr)
|
|
return
|
|
end if
|
|
|
|
bmode = matmul(bmat, mode)
|
|
binfl = matmul(bmat, influence)
|
|
modal_mass = dot_product(mode, bmode)
|
|
total_mass = dot_product(influence, binfl)
|
|
numerator = dot_product(mode, binfl)
|
|
if (modal_mass .le. tiny(ONE) .or. total_mass .le. tiny(ONE)) then
|
|
call error_set(FEM_ERR_SOLVER, 'modal effective mass has nonpositive mass', ierr)
|
|
return
|
|
end if
|
|
|
|
participation = numerator / modal_mass
|
|
eff_mass = numerator * numerator / (modal_mass * total_mass)
|
|
ierr = FEM_SUCCESS
|
|
end subroutine modal_effective_mass
|
|
|
|
end module fem_modal_analysis
|