diff --git a/src/IO/Update.jl b/src/IO/Update.jl deleted file mode 100644 index 2981ac78f..000000000 --- a/src/IO/Update.jl +++ /dev/null @@ -1,198 +0,0 @@ -using SolidStateDetectors.ConstructiveSolidGeometry: CSGUnion, CSGIntersection, CSGDifference, CSG_dict, - parse_r_of_primitive, parse_height_of_primitive, parse_translate_vector, parse_rotation_matrix -using SolidStateDetectors: construct_units -import SolidStateDetectors.ConstructiveSolidGeometry: Geometry, Dictionary -using SolidStateDetectors.ConstructiveSolidGeometry: AbstractGeometry, Transformations, - CSGUnion, CSGDifference, CSGIntersection, Cone, CartesianVector, HexagonalPrism -using OrderedCollections: OrderedDict -using IntervalSets -using Rotations -using StaticArrays -using Unitful -using JSON -using YAML - - -#old implementation of Constructive Solid Geometries: -function Geometry(::Type{T}, t::Type{CSGUnion}, dict::AbstractDict, input_units::NamedTuple, transformations::Transformations{T}) where {T} - @assert haskey(dict, "parts") "Please specify 'parts' of the '$(dict["type"])'." - sum( map(x-> Geometry(T, x, input_units, transformations), dict["parts"]) ) -end - -function Geometry(::Type{T}, ::Type{CSGIntersection}, dict::AbstractDict, input_units::NamedTuple, transformations::Transformations{T}) where {T} - @assert haskey(dict, "parts") "Please specify 'parts' of the '$(dict["type"])'." - parts = map(x-> Geometry(T, x, input_units, transformations), dict["parts"]) - reduce(&, parts) -end - -function Geometry(::Type{T}, ::Type{CSGDifference}, dict::AbstractDict, input_units::NamedTuple, transformations::Transformations{T}) where {T} - @assert haskey(dict, "parts") "Please specify 'parts' of the '$(dict["type"])'." - Geometry(T, dict["parts"][1], input_units, transformations) - sum( map(x-> Geometry(T, x, input_units, transformations), dict["parts"][2:end]) ) -end - -function Geometry(::Type{T}, dict::AbstractDict, input_units::NamedTuple, transformations::Transformations{T}) where {T} - if haskey(dict, "translate") - length_unit = input_units.length - t::CartesianVector{T} = parse_translate_vector(T, dict["translate"], length_unit) - gdict::AbstractDict{Any,Any} = filter(p -> first(p) != "translate", dict) - return Geometry(T, gdict, input_units, transformations) + t - end - Geometry(T, CSG_dict[dict["type"]], dict, input_units, transformations) -end - -function Geometry(::Type{T}, filename::String, input_units::NamedTuple, transformations::Transformations{T}) where {T} - @assert isfile(filename) "The given filename '$(filename)' does not lead to a valid file." - dict = if endswith(filename, ".json") - JSON.parsefile(filename) - elseif endswith(filename, ".yaml") - YAML.load_file(filename) - else - @error "Only JSON and YAML formats are supported at the moment." - end - Geometry(T, dict, input_units, transformations::Transformations{T}) -end - - -# UPDATE DUE TO BREAKING CHANGES TO TUBE/CONE: CENTERED AROUND ZERO -# AND REDEFINITION OF HEXAGONALPRISM -function update_primitives!(dict::AbstractDict, input_units::NamedTuple) - dict_keys = keys(dict) - #Translate all Tubes and Cone that are defined via "h" and where h is not zero - if "type" in dict_keys && dict["type"] == "HexagonalPrism" - rotZ = haskey(dict, "rotZ") ? dict["rotZ"] : 0 - rotZ -= input_units.angle == u"°" ? 30 : π/6 - rotZ = string(rotZ * input_units.angle) - delete!(dict, "rotZ") - if rotZ != 0 dict["rotate"] = Dict("Z" => rotZ) end - elseif "type" in dict_keys && dict["type"] in ["tube", "cone"] && "h" in dict_keys && dict["h"] != 0 - #add translate vector with z=0 if it does not exist - if !("translate" in dict_keys) dict["translate"] = Dict{String,Any}("z" => 0) end - dict["translate"]["z"] = dict["translate"]["z"] + Float64(dict["h"] / 2) - if dict["translate"]["z"] == 0 delete!(dict["translate"], "z") end - if length(keys(dict["translate"])) == 0 delete!(dict, "translate") end - end - for k in dict_keys - if typeof(dict[k]) <: AbstractDict - dict[k] = update_primitives!(dict[k], input_units) - elseif typeof(dict[k]) <: Array - for i in eachindex(dict[k]) - if typeof(dict[k][i]) <: AbstractDict - dict[k][i] = update_primitives!(dict[k][i], input_units) - end - end - end - end - dict -end - -function update_geometry!(g::AbstractDict, T::DataType, input_units = (length = NoUnits, angle = NoUnits)) - transformations::Transformations{T} = (rotation = one(SMatrix{3, 3, T, 9}), translation = zero(CartesianVector{T})) - g["geometry"] = Dictionary(Geometry(T, g["geometry"], input_units, transformations)) - return g -end - -function restructure_config_file_dict!(config_file_dict::AbstractDict, T::DataType = Float64) - - input_units = construct_units(config_file_dict) - update_primitives!(config_file_dict, input_units) - update_units = (length = NoUnits, angle = input_units.angle) - - t = broadcast(obj -> obj["type"], config_file_dict["objects"]) - - semiconductors = config_file_dict["objects"][findall(t .== "semiconductor")] - @assert length(semiconductors) == 1 "Config files need exactly one semiconductor per detector. This one has $(length(semiconductors)) semiconductors." - semiconductor = semiconductors[1] - - semiconductor = begin - delete!(semiconductor, "type") - if "charge_density_model" in keys(semiconductor) - semiconductor["impurity_density"] = semiconductor["charge_density_model"] - delete!(semiconductor, "charge_density_model") - end - update_geometry!(semiconductor, T, update_units) - semiconductor - end - - contacts = [ - begin - delete!(contact, "type") - if "channel" in keys(contact) - contact["id"] = contact["channel"] - delete!(contact, "channel") - end - update_geometry!(contact, T, update_units) - contact - end - for contact in config_file_dict["objects"][findall(t .== "contact")] - ] - - passives = [ - begin - delete!(passive, "type") - update_geometry!(passive, T, update_units) - passive - end - for passive in config_file_dict["objects"][findall(t .== "passive")] - ] - - virtual_drift_volumes = [ - begin - delete!(virtual_volume, "type") - update_geometry!(virtual_volume, T, update_units) - virtual_volume - end - for virtual_volume in config_file_dict["objects"][findall(t .== "virtual_drift_volume")] - ] - - - config_file_dict["detectors"] = [] - push!(config_file_dict["detectors"], OrderedDict{String, Any}("semiconductor" => semiconductor) ) - if length(contacts) > 0 config_file_dict["detectors"][1]["contacts"] = contacts end - if length(virtual_drift_volumes) > 0 config_file_dict["detectors"][1]["virtual_drift_volumes"] = virtual_drift_volumes end - if length(passives) > 0 config_file_dict["surroundings"] = passives end - - delete!(config_file_dict, "objects") - config_file_dict - -end - - -""" - update_config_file(filename::String)::String - -Updates the format of config files from v0.5.3 to v0.6. -Currently supported formats for the config file: .json, .yaml. -Returns the new filename (or an empty string if file could not be converted). -""" -function update_config_file(filename::String)::String - @assert isfile(filename) "'$(filename)' does not exist!" - - if endswith(filename, ".json") - data = JSON.parsefile(filename, dicttype = OrderedDict) - if !haskey(data, "objects") - @warn "The configuration file does not have the key 'objects'.\n"* - "Assuming that this configuration file has already been updated. Skipping..." - return "" - end - restructure_config_file_dict!(data) - new_filename = replace(filename, ".json" => "_updated.json") - open(new_filename,"w") do f - JSON.print(f, data, 4) - end - elseif endswith(filename, ".yaml") - data = YAML.load_file(filename, dicttype = OrderedDict) - if !haskey(data, "objects") - @warn "The configuration file does not have the key 'objects'.\n"* - "Assuming that this configuration file has already been updated. Skipping..." - return "" - end - restructure_config_file_dict!(data) - new_filename = replace(filename, ".yaml" => "_updated.yaml") - YAML.write_file(new_filename, data) - else - error("Currently only .json and .yaml files are supported.") - new_filename = "" - end - new_filename -end - diff --git a/src/Simulation/Simulation.jl b/src/Simulation/Simulation.jl index 1dee55e2b..5acbec9ac 100644 --- a/src/Simulation/Simulation.jl +++ b/src/Simulation/Simulation.jl @@ -1197,13 +1197,6 @@ function calculate_electric_field!(sim::Simulation{T, CS}; n_points_in_φ::Union nothing end -function calculate_drift_fields!(sim::Simulation{T}; - use_nthreads::Int = Base.Threads.nthreads())::Nothing where {T <: SSDFloat} - @warn "Since v0.7.0, drift fields do not need to be calculated anymore.\n`calculate_drift_fields!(sim)` can be removed." - nothing -end -@deprecate apply_charge_drift_model!(args...; kwargs...) calculate_drift_fields!(args...; kwargs...) - function drift_charges( sim::Simulation{T}, starting_positions::VectorOfArrays{CartesianPoint{T}}, energies::VectorOfArrays{T}; Δt::RealQuantity = 5u"ns", max_nsteps::Int = 1000, diffusion::Bool = false, self_repulsion::Bool = false, end_drift_when_no_field::Bool = true, geometry_check::Bool = false, verbose::Bool = true )::Vector{EHDriftPath{T}} where {T <: SSDFloat} diff --git a/src/SolidStateDetector/Passive.jl b/src/SolidStateDetector/Passive.jl index e4f2ae830..c27139e49 100644 --- a/src/SolidStateDetector/Passive.jl +++ b/src/SolidStateDetector/Passive.jl @@ -66,14 +66,6 @@ function Passive{T}(dict::AbstractDict, input_units::NamedTuple, outer_transform temperature::T = _parse_value(T, get(dict, "temperature", 293u"K"), input_units.temperature) charge_density_model = if haskey(dict, "charge_density") ChargeDensity(T, dict["charge_density"], input_units) - elseif haskey(dict, "charge_density_model") - @warn "Configuration file deprecation: There was an internal change from v0.5.3 to v0.6.0 regarding the - charge density of `Passive` objects. - Since v0.6.0, the elementary charge is not automatically multiplied to the distribution as it - is a charge density and not an impurity density. The values in the config files should be adapted - and the name of the field should be changed from \"charge_density_model\" into \"charge_density\". - This warning will result in an error in later versions." - ChargeDensity(T, dict["charge_density_model"], input_units) else ConstantChargeDensity{T}(0) end diff --git a/src/SolidStateDetector/Semiconductor.jl b/src/SolidStateDetector/Semiconductor.jl index a63e81b62..3fcdedc2f 100644 --- a/src/SolidStateDetector/Semiconductor.jl +++ b/src/SolidStateDetector/Semiconductor.jl @@ -51,12 +51,7 @@ end function Semiconductor{T}(dict::AbstractDict, input_units::NamedTuple, outer_transformations) where T <: SSDFloat impurity_density_model = if haskey(dict, "impurity_density") - imp = ImpurityDensity(T, dict["impurity_density"], input_units) - elseif haskey(dict, "charge_density_model") - @warn "Config file deprication: The field \"charge_density_model\" under semiconductor is deprecated. - It should be changed to \"impurity_density\". In later version this will result in an error. - For now, it will be treated as an impurity density." - ImpurityDensity(T, dict["charge_density_model"], input_units) + ImpurityDensity(T, dict["impurity_density"], input_units) else ConstantImpurityDensity{T}(0) end diff --git a/src/SolidStateDetector/SolidStateDetector.jl b/src/SolidStateDetector/SolidStateDetector.jl index b60cf7d8e..56b5ac3d3 100644 --- a/src/SolidStateDetector/SolidStateDetector.jl +++ b/src/SolidStateDetector/SolidStateDetector.jl @@ -98,23 +98,7 @@ function get_world_limits_from_objects(::Type{Cartesian}, det::SolidStateDetecto end function SolidStateDetector{T}(config_file::AbstractDict, input_units::NamedTuple) where {T <: SSDFloat} - - @assert !haskey(config_file, "objects") "Configuration file deprecation.\n - The configuration file format was updated in v0.6.0. - However, this configuration file still seems to be in the old format.\n - To update your configuration file to the new format (v0.6.0 and newer), - open a new Julia session and load the following file:\n - \tinclude(\"/test/update_config_files.jl\")\n - Afterwards, run\n - \tupdate_config_file(\"\")\n - This method returns the file name of the updated configuration file. - Please close the Julia session after updating the configuration files, as some - parsing methods are overridden with old methods.\n - Note that if your old geometries were defined using `difference`, you might - need to increase the dimensions of the subtracted geometry as it is now treated as - open primitive. Please have a look at the documentation:\n - \thttps://juliaphysics.github.io/SolidStateDetectors.jl/stable/\n" - + @assert haskey(config_file, "detectors") "Config file needs an entry `detectors` that defines the detector(s)." config_detector = config_file["detectors"][1] # still only one detector diff --git a/src/SolidStateDetectors.jl b/src/SolidStateDetectors.jl index 73c566552..daa8cb4bf 100644 --- a/src/SolidStateDetectors.jl +++ b/src/SolidStateDetectors.jl @@ -70,7 +70,7 @@ export Grid export ElectricPotential, PointTypes, EffectiveChargeDensity, DielectricDistribution, WeightingPotential, ElectricField export apply_initial_state! -export calculate_electric_potential!, calculate_weighting_potential!, calculate_electric_field!, calculate_drift_fields! +export calculate_electric_potential!, calculate_weighting_potential!, calculate_electric_field! export ElectricFieldChargeDriftModel, ADLChargeDriftModel, ADL2016ChargeDriftModel, IsotropicChargeDriftModel, InactiveLayerChargeDriftModel export LinearImpurityDensity, ThermalDiffusionLithiumDensity, PtypePNJunctionImpurityDensity export LinBouleImpurityDensity, ParBouleImpurityDensity, LinExpBouleImpurityDensity, ParExpBouleImpurityDensity, SplineBouleImpurityDensity diff --git a/test/update_config_files.jl b/test/update_config_files.jl deleted file mode 100644 index 215c731d1..000000000 --- a/test/update_config_files.jl +++ /dev/null @@ -1,17 +0,0 @@ -# The configuration file format was updated in v0.6.0. -# However, this configuration file still seems to be in the old format. -# -# To update your configuration file to the new format (v0.6.0 and newer), -# open a new Julia session and load this file through -# -# include("/test/update_config_files.jl") -# -# Afterwards, run -# -# update_config_file("") -# -# This method returns the file name of the updated configuration file. -# Please close the Julia session after updating the configuration files, as some -# parsing methods are overridden with old methods. - -include("../src/IO/Update.jl") \ No newline at end of file