Skip to content

Commit

Permalink
Showed a cross-section of a fiber bundle.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamazadi committed Nov 13, 2024
1 parent ee2a422 commit edebd5f
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 23 deletions.
4 changes: 3 additions & 1 deletion docs/src/newsreport.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,12 @@ This is related to the fact that the weak interaction in the Standard Model is n

![29](./assets/newsreport/29.PNG)

[How to glue two copies of the Riemann sphere (closed complex plane) together for clutching construction.](https://github.com/iamazadi/Porta.jl/blob/master/models/newsreport/gaugeconnections/fig155gluingspheres.jl)
[How to glue two copies of the Riemann sphere for constructing a vector bundle.](https://github.com/iamazadi/Porta.jl/blob/master/models/newsreport/gaugeconnections/fig155gluingspheres.jl)

![30](./assets/newsreport/30.PNG)

[A cross-section of a fiber bundle](https://github.com/iamazadi/Porta.jl/blob/master/models/newsreport/gaugeconnections/fig156crosssection.jl)

![31](./assets/newsreport/31.PNG)

![32](./assets/newsreport/32.PNG)
Expand Down
22 changes: 0 additions & 22 deletions models/newsreport/gaugeconnections/fig155gluingspheres.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FileIO
using GLMakie
import LinearAlgebra
using Porta


Expand All @@ -16,12 +15,6 @@ eyeposition = normalize(ℝ³(1.0, 0.0, 1.0)) * float(π)
lookat = ℝ³(0.0, 0.0, 0.0)
up = normalize(ℝ³(0.0, 0.0, 1.0))
sphereradius = 1.0
attributespath = "data/naturalearth/geometry-attributes.csv"
nodespath = "data/naturalearth/geometry-nodes.csv"
boundary_names = Set{String}()
boundary_nodes = Vector{Vector{ℝ³}}()
indices = Dict{String,Int}()
reference = load("data/basemap_color.png")
mask = load("data/basemap_mask.png")

makefigure() = Figure(size = figuresize)
Expand All @@ -30,21 +23,6 @@ pl = PointLight(Point3f(0), RGBf(0.0862, 0.0862, 0.0862))
al = AmbientLight(RGBf(0.9, 0.9, 0.9))
lscene = LScene(fig[1, 1], show_axis=false, scenekw = (lights = [pl, al], clear=true, backgroundcolor = :white))

## Load the Natural Earth data
countries = loadcountries(attributespath, nodespath)
while length(boundary_names) < 10
push!(boundary_names, rand(countries["name"]))
end
for i in eachindex(countries["name"])
for name in boundary_names
if countries["name"][i] == name
push!(boundary_nodes, countries["nodes"][i])
println(name)
indices[name] = length(boundary_nodes)
end
end
end

lspace1 = range(-π, stop = float(π), length = segments)
lspace2 = range(-π / 2, stop = π / 2, length = segments)
plane1 = [ℝ³([θ; ϕ; -1.0]) for θ in lspace2, ϕ in lspace1]
Expand Down
143 changes: 143 additions & 0 deletions models/newsreport/gaugeconnections/fig156crosssection.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using FileIO
using GLMakie
using Porta


figuresize = (4096, 2160)
segments = 90
frames_number = 360
modelname = "fig156crosssection"
= ℝ³([1.0; 0.0; 0.0])
= ℝ³([0.0; 1.0; 0.0])
= ℝ³([0.0; 0.0; 1.0])
eyeposition = normalize(ℝ³(1.0, 1.0, 1.0)) * float(π)
lookat = ℝ³(0.0, 0.0, 0.0)
up = normalize(ℝ³(0.0, 0.0, 1.0))
sphereradius = 1.0
mask = load("data/basemap_mask.png")
reference = load("data/basemap_color.png")
attributespath = "data/naturalearth/geometry-attributes.csv"
nodespath = "data/naturalearth/geometry-nodes.csv"
boundary_names = Set()
boundary_nodes = Vector{Vector{ℝ³}}()
points = Vector{Vector{ℍ}}()
indices = Dict()
T, X, Y, Z = vec(normalize(ℝ⁴(1.0, 0.0, 1.0, 0.0)))
u = 𝕍(T, X, Y, Z)
q = (T, X, Y, Z)
tolerance = 1e-3
@assert(isnull(u, atol = tolerance), "u in not a null vector, $u.")
@assert(isapprox(norm(q), 1, atol = tolerance), "q in not a unit quaternion, $(norm(q)).")
gauge1 = 0.0
gauge2 = π / 2
gauge3 = float(π)
gauge4 = 3π / 2
gauge5 = 2π
latitudescale = 1 / 2
longitudescale = 1 / 4
chart = (-π * latitudescale / 2, π * latitudescale / 2, -π * longitudescale, π * longitudescale)
M = Identity(4)

makefigure() = Figure(size = figuresize)
fig = with_theme(makefigure, theme_black())
pl = PointLight(Point3f(0), RGBf(0.0862, 0.0862, 0.0862))
al = AmbientLight(RGBf(0.9, 0.9, 0.9))
lscene1 = LScene(fig[1, 2], show_axis=true, scenekw = (lights = [pl, al], clear=true, backgroundcolor = :white))
lscene2 = LScene(fig[1, 1], show_axis=false, scenekw = (lights = [pl, al], clear=true, backgroundcolor = :white))

## Load the Natural Earth data
countries = loadcountries(attributespath, nodespath)
while length(boundary_names) < 10
push!(boundary_names, rand(countries["name"]))
end
for i in eachindex(countries["name"])
for name in boundary_names
if countries["name"][i] == name
push!(boundary_nodes, countries["nodes"][i])
println(name)
indices[name] = length(boundary_nodes)
end
end
end
for i in eachindex(boundary_nodes)
_points = Vector{ℍ}()
for node in boundary_nodes[i]
r, θ, ϕ = convert_to_geographic(node)
push!(_points, q * (exp* longitudescale * K(1) + θ * latitudescale * K(2))))
end
push!(points, _points)
end
basemap1 = Basemap(lscene2, q, gauge1, M, chart, segments, mask, transparency = true)
basemap2 = Basemap(lscene2, q, gauge2, M, chart, segments, mask, transparency = true)
basemap3 = Basemap(lscene2, q, gauge3, M, chart, segments, mask, transparency = true)
basemap4 = Basemap(lscene2, q, gauge4, M, chart, segments, mask, transparency = true)

whirls1 = []
whirls2 = []
whirls3 = []
whirls4 = []
for i in eachindex(boundary_nodes)
color1 = getcolor(boundary_nodes[i], reference, 0.2)
color2 = getcolor(boundary_nodes[i], reference, 0.4)
color3 = getcolor(boundary_nodes[i], reference, 0.6)
color4 = getcolor(boundary_nodes[i], reference, 0.8)
whirl1 = Whirl(lscene2, points[i], gauge1, gauge2, M, segments, color1, transparency = true)
whirl2 = Whirl(lscene2, points[i], gauge2, gauge3, M, segments, color2, transparency = true)
whirl3 = Whirl(lscene2, points[i], gauge3, gauge4, M, segments, color3, transparency = true)
whirl4 = Whirl(lscene2, points[i], gauge4, gauge5, M, segments, color4, transparency = true)
push!(whirls1, whirl1)
push!(whirls2, whirl2)
push!(whirls3, whirl3)
push!(whirls4, whirl4)
end

lspace1 = range(-π, stop = float(π), length = segments)
lspace2 = range(-π / 2, stop = π / 2, length = segments)
plane = [ℝ³([-θ; ϕ; 0.0]) * (1 / float(π)) for θ in lspace2, ϕ in lspace1]
sectionobservable = buildsurface(lscene1, plane, mask, transparency = true)
fibersobservable = Tuple{Observable{Matrix{Float64}}, Observable{Matrix{Float64}}, Observable{Matrix{Float64}}}[]
lspace = range(float(-π), stop = float(π), length = segments)
for index in 1:length(boundary_names)
boundary = convert_to_geographic.(boundary_nodes[index])
fiber = [ℝ³(vec(boundary[i])[2:3]..., height) * (1 / float(π)) for i in eachindex(boundary), height in lspace]
color = fill(getcolor(boundary_nodes[index], reference, 0.8), length(boundary), segments)
push!(fibersobservable, buildsurface(lscene1, fiber, color, transparency = true))
end


animate(frame::Int) = begin
progress = Float64(frame / frames_number)
println("Frame: $frame, Progress: $progress")
ψ = sin(progress * 2π) * π
plane = [ℝ³([-θ; ϕ; ψ]) * (1 / float(π)) for θ in lspace2, ϕ in lspace1]
updatesurface!(plane, sectionobservable)
update!(basemap1, q, gauge1 + ψ, M)
update!(basemap2, q, gauge2 + ψ, M)
update!(basemap3, q, gauge3 + ψ, M)
update!(basemap4, q, gauge4 + ψ, M)
points = Vector{Vector{ℍ}}()
for i in eachindex(boundary_nodes)
_points = Vector{ℍ}()
for node in boundary_nodes[i]
r, θ, ϕ = convert_to_geographic(node)
push!(_points, q * (exp* longitudescale * K(1) + θ * latitudescale * K(2))))
end
push!(points, _points)
end
for i in eachindex(whirls1)
update!(whirls1[i], points[i], gauge1 + ψ, gauge2 + ψ, M)
update!(whirls2[i], points[i], gauge2 + ψ, gauge3 + ψ, M)
update!(whirls3[i], points[i], gauge3 + ψ, gauge4 + ψ, M)
update!(whirls4[i], points[i], gauge4 + ψ, gauge5 + ψ, M)
end

updatecamera!(lscene1, eyeposition, sum(plane) * (1 / segments^2), up)
updatecamera!(lscene2, eyeposition, lookat, up)
end


animate(1)

record(fig, joinpath("gallery", "$modelname.mp4"), 1:frames_number) do frame
animate(frame)
end

0 comments on commit edebd5f

Please sign in to comment.