Skip to content

Commit

Permalink
Rename internal functions stretch_2[s] to sqrt_2[s]
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Jan 2, 2024
1 parent ac363ac commit 07e4f3d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. The format

## [Unreleased]

### Changed
- Rename internal matrix square-root from `stretch_2` and `stretch_2s` to `sqrt_2` and `sqrt_2s`. This does not affect the public API which remains unchanged as (matrix) square root `sqrt(T)`.

### Fixed
- Fix the orientation of `rotation_matrix(phi,2)` for a rotation matrix around axis 2. Also fix the docs for `rotation_matrix(phi,1)` and `rotation_matrix(phi,3)`.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/functions/squareroot.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ grand_parent: API Reference

## Square Root

Tensorial square root of a positive definite rank 2 Tensor. For algorithmic details see [Franka, L.P. (1988)](https://inis.iaea.org/search/search.aspx?orig_q=RN:20064555). This function can be used to obtain the stretch tensor.
Tensorial (matrix) square root of a positive definite rank 2 Tensor. For algorithmic details see [Franka, L.P. (1988)](https://inis.iaea.org/search/search.aspx?orig_q=RN:20064555). This function can be used to obtain the stretch tensor. For a rank 1 Tensor (vector), the element-wise square root is returned.

$$
\begin{align}
Expand Down
20 changes: 10 additions & 10 deletions ttb/libsqrt.f
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function sqrt_1(T)

end function sqrt_1

function stretch_2(T)
function sqrt_2(T)
! Source:
!
! Franca, L.P. (1989): AN ALGORITHM TO COMPUTE
Expand All @@ -17,7 +17,7 @@ function stretch_2(T)
implicit none

type(Tensor2), intent(in) :: T
type(Tensor2) :: stretch_2
type(Tensor2) :: sqrt_2

real(kind=8) :: I_T,II_T,III_T,I_U,II_U,III_U,k,l,lam,phi

Expand All @@ -30,7 +30,7 @@ function stretch_2(T)
! Isotropy check
if (dabs(k).le.1.0d-8) then
lam = (I_T/3.)**(1./2.)
stretch_2 = lam * identity2(T)
sqrt_2 = lam * identity2(T)
return
end if

Expand All @@ -46,12 +46,12 @@ function stretch_2(T)

print *, 'test', l,k,1-l**2/k**3

stretch_2 = 1./(I_U*II_U-III_U)
sqrt_2 = 1./(I_U*II_U-III_U)
* *(I_U*III_U*identity2(T) + (I_U**2-II_U)*T-T**2)

end function stretch_2
end function sqrt_2

function stretch_2s(T)
function sqrt_2s(T)
! Source:
!
! Franca, L.P. (1989): AN ALGORITHM TO COMPUTE
Expand All @@ -60,7 +60,7 @@ function stretch_2s(T)
implicit none

type(Tensor2s), intent(in) :: T
type(Tensor2s) :: stretch_2s
type(Tensor2s) :: sqrt_2s

real(kind=8) :: I_T,II_T,III_T,I_U,II_U,III_U,k,l,lam,phi

Expand All @@ -73,7 +73,7 @@ function stretch_2s(T)
! Isotropy check
if (k.le.1.0d-8) then
lam = (I_T/3.)**(1./2.)
stretch_2s = lam * identity2(T)
sqrt_2s = lam * identity2(T)
return
end if

Expand All @@ -87,7 +87,7 @@ function stretch_2s(T)
I_U = lam + dsqrt(-lam**2+I_T+2.*III_U/lam)
II_U = (I_U**2-I_T)/2.

stretch_2s = 1./(I_U*II_U-III_U)
sqrt_2s = 1./(I_U*II_U-III_U)
* *(I_U*III_U*identity2(T) + (I_U**2-II_U)*T-T*T)

end function stretch_2s
end function sqrt_2s
8 changes: 4 additions & 4 deletions ttb/ttb_library.f
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ module Tensor

interface sqrt
module procedure sqrt_1
module procedure stretch_2
module procedure stretch_2s
module procedure sqrt_2
module procedure sqrt_2s
end interface

interface dsqrt
module procedure sqrt_1
module procedure stretch_2
module procedure stretch_2s
module procedure sqrt_2
module procedure sqrt_2s
end interface

interface rotation_matrix
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0-dev
2.2.0-dev

0 comments on commit 07e4f3d

Please sign in to comment.