Skip to content

Commit 913c242

Browse files
committed
return streamfunc and potential from field_on_grid
1 parent 20f5e8e commit 913c242

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

Manifest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.0-rc3"
44
manifest_format = "2.0"
5-
project_hash = "1acd6ddf9d06c1be1ead153f3ed5ae7b14060395"
5+
project_hash = "dd0d912228d3570dd0b442fd72dbc8a9b466421d"
66

77
[[deps.ArgTools]]
88
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@@ -47,11 +47,11 @@ version = "1.6.0"
4747

4848
[[deps.Elliptic2]]
4949
deps = ["DelimitedFiles", "SpecialFunctions"]
50-
git-tree-sha1 = "6a65379fcb32951cff6f98602884b9364aa6e556"
50+
git-tree-sha1 = "fc0b6310c912f838661e19e739667d979683569c"
5151
repo-rev = "master"
5252
repo-url = "https://github.com/archermarx/Elliptic2.jl"
5353
uuid = "0b55928f-c416-41db-a823-c7dfe4e8fda4"
54-
version = "0.1.0"
54+
version = "0.2.0"
5555

5656
[[deps.FileWatching]]
5757
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopFieldCalc"
22
uuid = "896acac2-5fe1-47fe-8ead-27e3a9bc5c85"
33
authors = ["Thomas Marks <marksta@umich.edu> and contributors"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
Contour = "d38c429a-6771-53c6-b99e-75d170b6e991"
@@ -10,7 +10,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1010

1111
[compat]
1212
julia = "1"
13-
Elliptic2 = ">=0.2"
13+
Elliptic2 = ">=0.1"
1414
Contour = "0.6.2"
1515
Printf = "<0.0.1, 1"
1616

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ zs = -2.0:0.01:2.0
7070
# Define current loops. Here, we only have the single loop, defined above
7171
loops = [loop]
7272

73-
# Compute the magnetic field components
74-
Bx, By, Bz = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
73+
# Compute the magnetic field components, along with magnetic stream function and scalar potential
74+
Bx, By, Bz, streamfunc, potential = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
7575
```
7676

7777
You can write output of this function to a Tecplot-compatible ASCII data format
@@ -136,7 +136,7 @@ outer_coil = [
136136

137137
# Combine inner and outer coil loops into a single vector and compute field
138138
loops = [outer_coil; inner_coil]
139-
Bx, By, Bz = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
139+
Bx, By, Bz, streamfunc, potential = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
140140

141141
# Write output. By reversing z and y and transposing the magnetic field matrices, we
142142
# can rotate the output so that the loop axis is aligned with the x axis

examples/example_1.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ zs = -2.0:0.01:2.0
1616
loops = [loop]
1717

1818
# Compute the magnetic field components
19-
Bx, By, Bz = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
19+
Bx, By, Bz, _, _ = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
2020

2121
LoopFieldCalc.write_field("examples/example_1.dat", ys, zs, By[1, :, :], Bz[1, :, :])

examples/example_2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ outer_coil = [
4343

4444
# Combine inner and outer coil loops into a single vector and compute field
4545
loops = [outer_coil; inner_coil]
46-
Bx, By, Bz = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
46+
Bx, By, Bz, _, _ = LoopFieldCalc.field_on_grid(loops, xs, ys, zs)
4747

4848
# Write output. By reversing z and y and transposing the magnetic field matrices, we
4949
# can rotate the output so that the loop axis is aligned with the x axis

src/LoopFieldCalc.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,21 @@ function field_on_grid(loops, xs, ys, zs)
9191
Bx = zeros(Nx, Ny, Nz)
9292
By = zeros(Nx, Ny, Nz)
9393
Bz = zeros(Nx, Ny, Nz)
94+
streamfunc = zeros(Nx, Ny, Nz)
95+
potential = zeros(Nx, Ny, Nz)
9496

9597
for (i, x) in enumerate(xs), (j, y) in enumerate(ys), (k, z) in enumerate(zs)
9698
for loop in loops
97-
bx, by, bz, _, _ = field_at_point(loop, CartesianPoint(x, y, z))
99+
bx, by, bz, s, p = field_at_point(loop, CartesianPoint(x, y, z))
98100
Bx[i, j, k] += bx
99101
By[i, j, k] += by
100102
Bz[i, j, k] += bz
103+
streamfunc[i, j, k] += s
104+
potential[i, j, k] += p
101105
end
102106
end
103107

104-
return Bx, By, Bz
108+
return Bx, By, Bz, streamfunc, potential
105109
end
106110

107111
"""

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using LoopFieldCalc: CurrentLoop, CartesianPoint, CylindricalPoint, field_on_gri
4747
Bz_indiv = zeros(size(Bz))
4848

4949
for loop in loops
50-
Bx_i, By_i, Bz_i = field_on_grid([loop], xs, ys, zs)
50+
Bx_i, By_i, Bz_i, _, _ = field_on_grid([loop], xs, ys, zs)
5151
@. Bx_indiv += Bx_i
5252
@. By_indiv += By_i
5353
@. Bz_indiv += Bz_i

0 commit comments

Comments
 (0)