1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-09-17 18:51:17 +00:00

Fixed verlet_and_cell_lists

This commit is contained in:
Mo8it 2022-02-01 22:57:56 +01:00
parent f61d06ce1e
commit 341b1e8a85
10 changed files with 30 additions and 30 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
#Manifest.toml
Manifest.toml
exports
# Jupyter notebooks

View file

@ -131,10 +131,10 @@ uuid = "69e1c6dd-3888-40e6-b3c8-31ac5f578864"
version = "0.7.2"
[[deps.ChainRules]]
deps = ["ChainRulesCore", "Compat", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "Statistics"]
git-tree-sha1 = "3ce62c97bd166b8c810889fba131531c61e41dc8"
deps = ["ChainRulesCore", "Compat", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "SparseArrays", "Statistics"]
git-tree-sha1 = "849d4cb467ea3ecbbd3efe68dacd36f9429b543c"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "1.25.0"
version = "1.26.0"
[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
@ -294,9 +294,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[deps.Distributions]]
deps = ["ChainRulesCore", "DensityInterface", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Test"]
git-tree-sha1 = "c6dd4a56078a7760c04b882d9d94a08a4669598d"
git-tree-sha1 = "24d26ca2197c158304ab2329af074fbe14c988e4"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.44"
version = "0.25.45"
[[deps.DocStringExtensions]]
deps = ["LibGit2"]
@ -456,9 +456,9 @@ version = "3.4.1"
[[deps.GLFW_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libglvnd_jll", "Pkg", "Xorg_libXcursor_jll", "Xorg_libXi_jll", "Xorg_libXinerama_jll", "Xorg_libXrandr_jll"]
git-tree-sha1 = "0c603255764a1fa0b61752d2bec14cfbd18f7fe8"
git-tree-sha1 = "51d2dfe8e590fbd74e7a842cf6d13d8a2f45dc01"
uuid = "0656b61e-2033-5cc2-a64a-77c0f6c09b89"
version = "3.3.5+1"
version = "3.3.6+0"
[[deps.GLMakie]]
deps = ["ColorTypes", "Colors", "FileIO", "FixedPointNumbers", "FreeTypeAbstraction", "GLFW", "GeometryBasics", "LinearAlgebra", "Makie", "Markdown", "MeshIO", "ModernGL", "Observables", "Printf", "Serialization", "ShaderAbstractions", "StaticArrays"]
@ -674,9 +674,9 @@ version = "0.4.19"
[[deps.JLLWrappers]]
deps = ["Preferences"]
git-tree-sha1 = "22df5b96feef82434b07327e2d3c770a9b21e023"
git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.4.0"
version = "1.4.1"
[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]

View file

@ -10,14 +10,14 @@ function gen_elliptical_distance_graphics()
fig = gen_figure()
ax = Axis(fig[1, 1]; xlabel=L"x", ylabel=L"y", aspect=AxisAspect(1))
ax = Axis(fig[1, 1]; xlabel=L"x", ylabel=L"y")
elliptical_a_b_ratio = 0.4
elliptical_b_a_ratio = 0.4
as = 1:1:3
for a in as
x = collect(LinRange(-a, a, 1000))
y = @. sqrt(a^2 - x^2) * elliptical_a_b_ratio
y = @. sqrt(a^2 - x^2) * elliptical_b_a_ratio
append!(x, reverse(x))
append!(y, reverse(-y))
lines!(x, y; label=L"a = %$a")

View file

@ -5,7 +5,7 @@ using StaticArrays: SVector
using ReCo: ReCo
function gen_verlet_and_cell_lists_graphics()
Random.seed!(23)
Random.seed!(3)
box_length = 100
@ -26,11 +26,11 @@ function gen_verlet_and_cell_lists_graphics()
circle(Point(reference_particle_x, reference_particle_y), R_particle, :fill)
reference_particle_c = SVector(reference_particle_x, reference_particle_y)
N = 91
N = 107
particle_cs = Vector{SVector{2,Float64}}(undef, N)
distance_limit = 0.99 * 2 * particle_radius
distance_limit = 0.98 * 2 * R_particle
x = y = distance = 0.0

View file

@ -9,7 +9,7 @@ struct EnvHelperSharedProps{H<:AbstractHook}
n_actions_updates_per_episode::Int64
reward_normalization::Float64
elliptical_a_b_ratio::Float64
elliptical_b_a_ratio::Float64
n_particles::Int64
@ -25,7 +25,7 @@ struct EnvHelperSharedProps{H<:AbstractHook}
hook::H,
n_steps_before_actions_update::Int64,
n_actions_updates_per_episode::Int64,
elliptical_a_b_ratio::Float64,
elliptical_b_a_ratio::Float64,
n_particles::Int64,
) where {H<:AbstractHook}
reward_normalization = n_particles * n_actions_updates_per_episode
@ -37,7 +37,7 @@ struct EnvHelperSharedProps{H<:AbstractHook}
n_steps_before_actions_update,
n_actions_updates_per_episode,
reward_normalization,
elliptical_a_b_ratio,
elliptical_b_a_ratio,
n_particles,
fill(0, n_particles),
fill(0, n_particles),

View file

@ -61,7 +61,7 @@ mutable struct COMCompassEnvHelper <: EnvHelper
function COMCompassEnvHelper(shared::EnvHelperSharedProps, half_box_len::Float64)
max_elliptical_distance = sqrt(
half_box_len^2 + (half_box_len / shared.elliptical_a_b_ratio)^2
half_box_len^2 + (half_box_len / shared.elliptical_b_a_ratio)^2
)
return new(
@ -145,7 +145,7 @@ function update_reward!(
env_helper.center_of_mass,
env_helper.gyration_tensor_eigvec_to_smaller_eigval,
env_helper.gyration_tensor_eigvec_to_bigger_eigval,
env_helper.shared.elliptical_a_b_ratio,
env_helper.shared.elliptical_b_a_ratio,
env_helper.half_box_len,
)

View file

@ -58,7 +58,7 @@ mutable struct LocalCOMWithAdditionalShapeRewardEnvHelper <: EnvHelper
shared::EnvHelperSharedProps, half_box_len::Float64, skin_radius::Float64
)
max_elliptical_distance = sqrt(
half_box_len^2 + (half_box_len / shared.elliptical_a_b_ratio)^2
half_box_len^2 + (half_box_len / shared.elliptical_b_a_ratio)^2
)
max_distance_to_local_center_of_mass = skin_radius
@ -188,7 +188,7 @@ function update_reward!(
env_helper.center_of_mass,
env_helper.gyration_tensor_eigvec_to_smaller_eigval,
env_helper.gyration_tensor_eigvec_to_bigger_eigval,
env_helper.shared.elliptical_a_b_ratio,
env_helper.shared.elliptical_b_a_ratio,
env_helper.half_box_len,
)

View file

@ -61,7 +61,7 @@ mutable struct OriginCompassEnvHelper <: EnvHelper
function OriginCompassEnvHelper(shared::EnvHelperSharedProps, half_box_len::Float64)
max_elliptical_distance = sqrt(
half_box_len^2 + (half_box_len / shared.elliptical_a_b_ratio)^2
half_box_len^2 + (half_box_len / shared.elliptical_b_a_ratio)^2
)
return new(
@ -143,7 +143,7 @@ function update_reward!(
env_helper.center_of_mass,
env_helper.gyration_tensor_eigvec_to_smaller_eigval,
env_helper.gyration_tensor_eigvec_to_bigger_eigval,
env_helper.shared.elliptical_a_b_ratio,
env_helper.shared.elliptical_b_a_ratio,
env_helper.half_box_len,
)

View file

@ -66,7 +66,7 @@ end
function run_rl(;
EnvType::Type{E},
process_dir::String,
elliptical_a_b_ratio::Float64=1.0,
elliptical_b_a_ratio::Float64=1.0,
n_episodes::Int64=200,
episode_duration::Float64=50.0,
update_actions_at::Float64=0.1,
@ -80,7 +80,7 @@ function run_rl(;
show_simulation_progress::Bool=true,
n_episodes_before_env_helper_saving::Int64=10,
) where {E<:Env}
@assert 0.0 <= elliptical_a_b_ratio <= 1.0
@assert 0.0 <= elliptical_b_a_ratio <= 1.0
@assert n_episodes > 0
@assert episode_duration > 0
@assert update_actions_at in 0.001:0.001:episode_duration
@ -116,7 +116,7 @@ function run_rl(;
hook,
n_steps_before_actions_update,
n_actions_updates_per_episode,
elliptical_a_b_ratio,
elliptical_b_a_ratio,
n_particles,
)

View file

@ -161,7 +161,7 @@ function elliptical_distance(
COM::SVector{2,<:Real},
gyration_tensor_eigvec_to_smaller_eigval::SVector{2,<:Real},
gyration_tensor_eigvec_to_bigger_eigval::SVector{2,<:Real},
elliptical_a_b_ratio::Real,
elliptical_b_a_ratio::Real,
half_box_len::Real,
)
v = ReCo.restrict_coordinates(v - COM, half_box_len)
@ -169,7 +169,7 @@ function elliptical_distance(
x = LA.dot(v, gyration_tensor_eigvec_to_bigger_eigval)
y = LA.dot(v, gyration_tensor_eigvec_to_smaller_eigval)
return sqrt(x^2 + (y / elliptical_a_b_ratio)^2)
return sqrt(x^2 + (y / elliptical_b_a_ratio)^2)
end
end # module