Skip to content

Commit

Permalink
Generalize struct type
Browse files Browse the repository at this point in the history
  • Loading branch information
henry2004y committed Apr 14, 2024
1 parent 2f9554d commit b4fcd75
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utility/confinement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
using Elliptic: ellipke
using SpecialFunctions: erf


struct Currentloop{T<:AbstractFloat}
#TODO Generalize the geometry
struct Currentloop{T<:AbstractFloat, Vl, Vn}
"radius of coil loop [m]"
a::T
"steady current [A]"
I::T
"location of loop center [m]"
location::Vector{T}
location::Vl
"unit orientation of the loop (currently only support ẑ)"
normal::Vector{T}
normal::Vn
end

function getB_current_loop(x, y, z, cl::Currentloop)
Expand Down Expand Up @@ -40,8 +40,8 @@ Get magnetic field at `[x, y, z]` from a magnetic mirror generated from two coil
- `I1::Float`: current in the solenoid times number of windings in side coils.
"""
function getB_mirror(x, y, z, distance, a, I1)
cl1 = Currentloop(a, I1, [0.0, 0.0, -0.5*distance], [0.0, 0.0, 1.0])
cl2 = Currentloop(a, I1, [0.0, 0.0, 0.5*distance], [0.0, 0.0, 1.0])
cl1 = Currentloop(a, I1, SA[0.0, 0.0, -0.5*distance], SA[0.0, 0.0, 1.0])
cl2 = Currentloop(a, I1, SA[0.0, 0.0, 0.5*distance], SA[0.0, 0.0, 1.0])
B1 = getB_current_loop(x, y, z, cl1)
B2 = getB_current_loop(x, y, z, cl2)
# total magnetic field
Expand All @@ -65,16 +65,16 @@ Reference: https://en.wikipedia.org/wiki/Magnetic_mirror#Magnetic_bottles
- `distance::Float`: distance between solenoids in [m].
- `a::Float`: radius of each side coil in [m].
- `b::Float`: radius of central coil in [m].
- `I1::Float`: current in the solenoid times number of windings in side coils.
- `I1::Float`: current in the solenoid times number of windings in side coils in [A].
- `I2::Float`: current in the central solenoid times number of windings in the
central loop.
central loop in [A].
"""
function getB_bottle(x, y, z, distance, a, b, I1, I2)
r = (x^2 + y^2) # distance from z-axis

B = getB_mirror(x, y, z, distance, a, I1)
# Central loop
cl3 = Currentloop(a, I1, [0.0, 0.0, 0.0], [0.0, 0.0, 1.0])
cl3 = Currentloop(a, I1, SA[0.0, 0.0, 0.0], SA[0.0, 0.0, 1.0])
B3 = getB_current_loop(x, y, z, cl3)
# total magnetic field
if x == 0.0 && y == 0.0
Expand Down

2 comments on commit b4fcd75

@henry2004y
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/104891

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.3 -m "<description of version>" b4fcd75b5847afeb95e0c3577a0190723c581c9a
git push origin v0.10.3

Please sign in to comment.