1
0
Fork 0
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:
MoBit 2021-12-03 14:41:01 +01:00
parent 27591af18b
commit ea1d06e02b

View file

@ -1,4 +1,4 @@
using StaticArrays: SVector
using StaticArrays: SVector, SMatrix
function project_to_unit_circle(x, l)
φ = (x + l) * π / l
@ -43,3 +43,23 @@ function center_of_mass(args)
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