mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-12-21 00:51:21 +00:00
gyration_tensor
This commit is contained in:
parent
27591af18b
commit
ea1d06e02b
1 changed files with 21 additions and 1 deletions
22
src/shape.jl
22
src/shape.jl
|
@ -1,4 +1,4 @@
|
|||
using StaticArrays: SVector
|
||||
using StaticArrays: SVector, SMatrix
|
||||
|
||||
function project_to_unit_circle(x, l)
|
||||
φ = (x + l) * π / l
|
||||
|
@ -42,4 +42,24 @@ function center_of_mass(args)
|
|||
project_back_from_unit_circle(x_θ, args.l),
|
||||
project_back_from_unit_circle(y_θ, args.l),
|
||||
)
|
||||
end
|
||||
|
||||
function gyration_tensor(args)
|
||||
COM = center_of_mass(args)
|
||||
|
||||
S11 = 0.0
|
||||
S12 = 0.0
|
||||
S22 = 0.0
|
||||
|
||||
for p in args.particles
|
||||
c = p.c
|
||||
x = c[1] - COM[1]
|
||||
y = c[2] - COM[2]
|
||||
|
||||
S11 += x^2
|
||||
S12 += x * y
|
||||
S22 += y^2
|
||||
end
|
||||
|
||||
return SMatrix{2,2}(S11, S12, S12, S22)
|
||||
end
|
Loading…
Reference in a new issue