mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +00:00
Added eigenvals_ratio
This commit is contained in:
parent
dbbe3222bf
commit
79a7f84808
1 changed files with 11 additions and 7 deletions
18
src/shape.jl
18
src/shape.jl
|
@ -1,4 +1,5 @@
|
||||||
using StaticArrays: SVector, SMatrix
|
using StaticArrays: SVector, SMatrix
|
||||||
|
using LinearAlgebra: eigvals, Hermitian
|
||||||
|
|
||||||
function project_to_unit_circle(x, l)
|
function project_to_unit_circle(x, l)
|
||||||
φ = (x + l) * π / l
|
φ = (x + l) * π / l
|
||||||
|
@ -24,15 +25,13 @@ function center_of_mass(args)
|
||||||
|
|
||||||
# No need for 1/N with atan
|
# No need for 1/N with atan
|
||||||
# If proj is (0, 0) then COM is 0 or L or -L. Here, 0 is choosen with θ = π
|
# If proj is (0, 0) then COM is 0 or L or -L. Here, 0 is choosen with θ = π
|
||||||
if (round(x_proj_sum[1]; digits=digits) == 0) &&
|
if round(x_proj_sum[1]; digits=digits) == round(x_proj_sum[2]; digits=digits) == 0
|
||||||
(round(x_proj_sum[2]; digits=digits) == 0)
|
|
||||||
x_θ = π
|
x_θ = π
|
||||||
else
|
else
|
||||||
x_θ = atan(x_proj_sum[2], x_proj_sum[1])
|
x_θ = atan(x_proj_sum[2], x_proj_sum[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
if (round(y_proj_sum[1]; digits=digits) == 0) &&
|
if round(y_proj_sum[1]; digits=digits) == round(y_proj_sum[2]; digits=digits) == 0
|
||||||
(round(y_proj_sum[2]; digits=digits) == 0)
|
|
||||||
y_θ = π
|
y_θ = π
|
||||||
else
|
else
|
||||||
y_θ = atan(y_proj_sum[2], y_proj_sum[1])
|
y_θ = atan(y_proj_sum[2], y_proj_sum[1])
|
||||||
|
@ -53,13 +52,18 @@ function gyration_tensor(args)
|
||||||
|
|
||||||
for p in args.particles
|
for p in args.particles
|
||||||
c = p.c
|
c = p.c
|
||||||
x = c[1] - COM[1]
|
x = restrict_coordinate(c[1] - COM[1]; l=args.l)
|
||||||
y = c[2] - COM[2]
|
y = restrict_coordinate(c[2] - COM[2]; l=args.l)
|
||||||
|
|
||||||
S11 += x^2
|
S11 += x^2
|
||||||
S12 += x * y
|
S12 += x * y
|
||||||
S22 += y^2
|
S22 += y^2
|
||||||
end
|
end
|
||||||
|
|
||||||
return SMatrix{2,2}(S11, S12, S12, S22)
|
return Hermitian(SMatrix{2,2}(S11, S12, S12, S22))
|
||||||
|
end
|
||||||
|
|
||||||
|
function gyration_tensor_eigvals_ratio(args)
|
||||||
|
ev = eigvals(gyration_tensor(args)) # Eigenvalues are sorted
|
||||||
|
return ev[1] / ev[2]
|
||||||
end
|
end
|
Loading…
Reference in a new issue