Skip to content

Commit b893dfd

Browse files
committed
Fix validating the input to linear and cylindrical impurity/charge density (#574)
* Fix validating the input to linear and cylindrical impurity/charge density * Fix impurity density for test detector
1 parent 93561eb commit b893dfd

File tree

6 files changed

+5
-11
lines changed

6 files changed

+5
-11
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
impurity_density:
22
name: linear
3-
phi:
4-
init: 0
5-
gradient: 0
6-
r:
7-
init: 0
8-
gradient: 0
93
z:
104
init: -10000000
115
gradient: -100000

src/ChargeDensities/CylindricalChargeDensity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function ChargeDensity(T::DataType, t::Val{:cylindrical}, dict::AbstractDict, in
3232
offsets, gradients = zeros(T,3), zeros(T,3)
3333
density_unit = internal_charge_unit * input_units.length^(-3)
3434
density_gradient_unit = internal_charge_unit * input_units.length^(-4)
35-
if prod(map(k -> k in ["r","z"], collect(keys(dict)))) @warn "Only r and z are supported in the cylindrical charge density model.\nChange the charge density model in the config file or remove all other entries." end
35+
if !prod(map(k -> k in ("r","z"), filter(x -> x != "name", collect(keys(dict))))) @warn "Only r and z are supported in the cylindrical charge density model.\nChange the charge density model in the config file or remove all other entries." end
3636
if haskey(dict, "r")
3737
if haskey(dict["r"], "init") offsets[1] = _parse_value(T, dict["r"]["init"], density_unit) end
3838
if haskey(dict["r"], "gradient") gradients[1] = _parse_value(T, dict["r"]["gradient"], density_gradient_unit) end

src/ChargeDensities/LinearChargeDensity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function ChargeDensity(T::DataType, t::Val{:linear}, dict::AbstractDict, input_u
3131
offsets, gradients = zeros(T,3), zeros(T,3)
3232
density_unit = internal_charge_unit * input_units.length^(-3)
3333
density_gradient_unit = internal_charge_unit * input_units.length^(-4)
34-
if prod(map(k -> k in ["x","y","z"], collect(keys(dict)))) @warn "Only x, y and z are supported in the linear charge density model.\nChange the charge density model in the config file or remove all other entries." end
34+
if !prod(map(k -> k in ("x","y","z"), filter(x -> x != "name", collect(keys(dict))))) @warn "Only x, y and z are supported in the linear charge density model.\nChange the charge density model in the config file or remove all other entries." end
3535
if haskey(dict, "x")
3636
if haskey(dict["x"], "init") offsets[1] = _parse_value(T, dict["x"]["init"], density_unit) end
3737
if haskey(dict["x"], "gradient") gradients[1] = _parse_value(T, dict["x"]["gradient"], density_gradient_unit) end

src/ImpurityDensities/CylindricalImpurityDensity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function ImpurityDensity(T::DataType, t::Val{:cylindrical}, dict::AbstractDict,
3232
offsets, gradients = zeros(T,3), zeros(T,3)
3333
density_unit = input_units.length^(-3)
3434
density_gradient_unit = input_units.length^(-4)
35-
if prod(map(k -> k in ["r","z"], collect(keys(dict)))) @warn "Only r and z are supported in the cylindrical impurity density model.\nChange the impurity density model in the config file or remove all other entries." end
35+
if !prod(map(k -> k in ("r","z"), filter(x -> !(x in ("name", "corrections")), collect(keys(dict))))) @warn "Only r and z are supported in the cylindrical impurity density model.\nChange the impurity density model in the config file or remove all other entries." end
3636
if haskey(dict, "r")
3737
if haskey(dict["r"], "init") offsets[1] = _parse_value(T, dict["r"]["init"], density_unit) end
3838
if haskey(dict["r"], "gradient") gradients[1] = _parse_value(T, dict["r"]["gradient"], density_gradient_unit) end

src/ImpurityDensities/LinearImpurityDensity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function ImpurityDensity(T::DataType, t::Val{:linear}, dict::AbstractDict, input
3131
offsets, gradients = zeros(T,3), zeros(T,3)
3232
density_unit = input_units.length^(-3)
3333
density_gradient_unit = input_units.length^(-4)
34-
if prod(map(k -> k in ["x","y","z"], collect(keys(dict)))) @warn "Only x, y and z are supported in the linear impurity density model.\nChange the impurity density model in the config file or remove all other entries." end
34+
if !prod(map(k -> k in ("x","y","z"), filter(x -> !(x in ("name", "corrections")), collect(keys(dict))))) @warn "Only x, y and z are supported in the linear impurity density model.\nChange the impurity density model in the config file or remove all other entries." end
3535
if haskey(dict, "x")
3636
if haskey(dict["x"], "init") offsets[1] = _parse_value(T, dict["x"]["init"], density_unit) end
3737
if haskey(dict["x"], "gradient") gradients[1] = _parse_value(T, dict["x"]["gradient"], density_gradient_unit) end

test/test_geant4.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
@testset "Run Geant4 simulations" begin
5858

5959
# Create G4JLApplication
60-
sim = Simulation{T}(SSD_examples[:InvertedCoaxInCryostat])
60+
sim = @test_nowarn Simulation{T}(SSD_examples[:InvertedCoaxInCryostat])
6161
source = MonoenergeticSource("gamma", 2.615u"MeV", CartesianPoint(0.04, 0, 0.05), CartesianVector(-1,0,0))
6262
app = Geant4.G4JLApplication(sim, source)
6363

0 commit comments

Comments
 (0)