@@ -115,13 +115,11 @@ function magneticField(tDesign::SphericalTDesign, field::Union{AbstractArray{T,2
115
115
x, y, z,
116
116
calcSolid)
117
117
end
118
-
119
-
120
118
121
- function magneticField (coords:: AbstractArray{T,2} , field:: Union{AbstractArray{T,2},AbstractArray{T,3}} ,
122
- R:: T , center:: Vector{T} , L:: Int ,
123
- x:: Variable , y:: Variable , z:: Variable ,
124
- calcSolid:: Bool = true ) where T <: Real
119
+ function magneticField (coords:: AbstractArray{T, 2} , field:: Union{AbstractArray{T, 2}, AbstractArray{T, 3}} ,
120
+ R:: T , center:: Vector{T} , L:: Int ,
121
+ x:: Variable , y:: Variable , z:: Variable ,
122
+ calcSolid:: Bool = true ) where T <: Real
125
123
126
124
# transpose coords if its dimensions do not fit
127
125
if size (coords,1 ) != 3
@@ -145,20 +143,19 @@ function magneticField(coords::AbstractArray{T,2}, field::Union{AbstractArray{T,
145
143
for c in axes (field,3 )
146
144
# calculation of the coefficients
147
145
for j in axes (field,1 )
146
+ coeffs[j,c] = SphericalHarmonicExpansions. sphericalQuadrature (field[j,:,c],coords' ,L);
147
+ coeffs[j,c]. R = R
148
148
149
- coeffs[j,c] = SphericalHarmonicExpansions. sphericalQuadrature (field[j,:,c],coords' ,L);
150
- coeffs[j,c]. R = R
149
+ normalize! (coeffs[j,c],R)
151
150
152
- normalize! (coeffs[j,c],R)
153
-
154
- # convert spherical into solid coefficients
155
- if calcSolid
156
- solid! (coeffs[j,c])
157
- end
151
+ # convert spherical into solid coefficients
152
+ if calcSolid
153
+ solid! (coeffs[j,c])
154
+ end
158
155
159
- # calculation of the expansion
160
- expansion[j,c] = sphericalHarmonicsExpansion (coeffs[j,c],x,y,z) + 0 * x;
161
- func[j,c] = @fastfunc expansion[j,c]+ 0 * x+ 0 * y+ 0 * z
156
+ # calculation of the expansion
157
+ expansion[j,c] = sphericalHarmonicsExpansion (coeffs[j,c],x,y,z) + 0 * x;
158
+ func[j,c] = @fastfunc expansion[j,c]+ 0 * x+ 0 * y+ 0 * z
162
159
end
163
160
end
164
161
@@ -190,25 +187,23 @@ function loadTDesign(filename::String)
190
187
return coeffs_MF, expansion, func
191
188
end
192
189
193
-
194
- Base. @kwdef mutable struct SphericalHarmonicDefinedField <: AbstractMagneticField
190
+ export SphericalHarmonicsDefinedField
191
+ Base. @kwdef mutable struct SphericalHarmonicsDefinedField <: AbstractMagneticField
195
192
func:: Array{Function, 2}
196
193
patch:: Integer = 1
197
194
end
198
195
199
- function SphericalHarmonicDefinedField (filename:: String )
196
+ function SphericalHarmonicsDefinedField (filename:: String )
200
197
coeffs_MF, expansion, func = loadTDesign (filename)
201
- return SphericalHarmonicDefinedField (func= func)
198
+ return SphericalHarmonicsDefinedField (func= func)
202
199
end
203
200
204
- MPIMagneticFields. fieldType (:: SphericalHarmonicDefinedField ) = OtherField ()
205
- MPIMagneticFields. definitionType (:: SphericalHarmonicDefinedField ) = SphericalHarmonicsDataBasedFieldDefinition ()
206
- MPIMagneticFields. timeDependencyType (:: SphericalHarmonicDefinedField ) = TimeConstant ()
201
+ MPIMagneticFields. fieldType (:: SphericalHarmonicsDefinedField ) = OtherField ()
202
+ MPIMagneticFields. definitionType (:: SphericalHarmonicsDefinedField ) = SphericalHarmonicsDataBasedFieldDefinition ()
203
+ MPIMagneticFields. timeDependencyType (:: SphericalHarmonicsDefinedField ) = TimeConstant ()
207
204
208
- # TODO : Maybe use StaticArrays here
209
- MPIMagneticFields. value (field:: SphericalHarmonicDefinedField , r:: Vector{T} ) where T <: Number = [field. func[i, field. patch]. (r... ) for i= 1 : 3 ]
210
- MPIMagneticFields. value (field:: SphericalHarmonicDefinedField , r) = [MPIMagneticFields. value (field, [x, y, z]) for x in r[1 ], y in r[2 ], z in r[3 ]]
205
+ MPIMagneticFields. value (field:: SphericalHarmonicsDefinedField , r:: PT ) where {T <: Number , PT <: AbstractVector{T} } = [field. func[i, field. patch]. (r... ) for i= 1 : 3 ]
211
206
212
- selectPatch (field:: SphericalHarmonicDefinedField , patchNum) = field. patch = patchNum
207
+ selectPatch (field:: SphericalHarmonicsDefinedField , patchNum) = field. patch = patchNum
213
208
214
209
end
0 commit comments