### Accessing Example Configuration Paths in SolidStateDetectors.jl Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Use this to get the full path to example configuration files provided by the SolidStateDetectors.jl package. ```julia using SolidStateDetectors keys(SSD_examples) # dictionary holding the full path to the corresponding configuration files ``` -------------------------------- ### List Example Primitive Configuration Files Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Lists all available example primitive configuration files from the SolidStateDetectors.jl package. This helps in understanding the available primitive definitions. ```julia path_to_example_primitives_config_files = joinpath(dirname(dirname(pathof(SolidStateDetectors))), "examples", "example_primitive_files") example_primitives_config_filenames = readdir(path_to_example_primitives_config_files) for fn in example_primitives_config_filenames println(fn) end ``` -------------------------------- ### Initialize Simulation for Plotting Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/plotting.md Setup the simulation environment and calculate results required for visualization. ```julia using Plots using SolidStateDetectors using Unitful T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]); simulate!(sim, convergence_limit = 1e-6, refinement_limits = [0.2, 0.1, 0.05, 0.01]); ``` -------------------------------- ### Configure Doctest Setup Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/api.md Sets up the environment for doctests by importing the necessary modules. ```julia DocTestSetup = quote using SolidStateDetectors using SolidStateDetectors.ConstructiveSolidGeometry end ``` -------------------------------- ### Setup Grid Data Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Initializes the basic data structures for grid visualization. ```julia using Plots, LaTeXStrings #hide xs = [1,2,3,4,5,6,7,8,9] #hide ys = [0.38,0.46,0.48,0.44,0.35,0.28,0.2,0.15,0.1] #hide nothing #hide ``` -------------------------------- ### Example Refinement Limits in Julia Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Demonstrates how to set refinement limits for grid refinement in simulations. This example shows a simple list of values for each dimension across multiple refinement steps. ```julia refinement_limits = [0.2, 0.1, 0.05] ``` -------------------------------- ### Install LegendHDF5IO Packages Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/IO.md Install the necessary unregistered packages for HDF5 support by providing their Git URLs to Pkg.add. ```julia import Pkg Pkg.add(url="https://github.com/legend-exp/LegendDataTypes.jl.git") Pkg.add(url="https://github.com/legend-exp/LegendHDF5IO.jl.git") ``` -------------------------------- ### Install SolidStateDetectors.jl Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Use the Julia package manager to add SolidStateDetectors.jl to your environment. ```julia using Pkg pkg"add SolidStateDetectors" ``` -------------------------------- ### Loading a Simulation with a Configuration File Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Load a simulation environment by providing the path to a configuration file. Ensure the path is correctly obtained, for example, using `SSD_examples`. ```julia path_to_config_file = SSD_examples[:InvertedCoax] sim = Simulation(path_to_config_file) ``` -------------------------------- ### Create Simulation from Configuration Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Load a detector configuration from a YAML file or use built-in examples to create a simulation object. ```julia using SolidStateDetectors using Unitful # Create simulation from a configuration file path sim = Simulation{Float32}("path/to/detector_config.yaml") # Or use built-in example detectors sim = Simulation{Float32}(SSD_examples[:InvertedCoax]) # List available example detectors keys(SSD_examples) ``` -------------------------------- ### Configure Charge Density via YAML Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/electric_potential.md Example configuration for defining a constant charge density in units of Coulomb per volume. ```yaml charge_density: name: constant value: 1e-10 # => 10⁻¹⁰ C/m³ ``` -------------------------------- ### Install and Load Plots.jl Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/installation.md Install the Plots.jl package and load it to enable plotting recipes provided by SolidStateDetectors. ```julia using Pkg; pkg"add Plots" ``` ```julia using Plots ``` -------------------------------- ### Configure ADLChargeDriftModel via YAML Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Example configuration file for the ADLChargeDriftModel using Bruyneel 2006 parameters. ```yaml model: ADLChargeDriftModel phi110: -45° material: HPGe drift: velocity: model: Bruyneel2006 parameters: e100: mu0: 38609cm^2/(V*s) beta: 0.805 E0: 511V/cm mun: -171cm^2/(V*s) e111: mu0: 38536cm^2/(V*s) beta: 0.641 E0: 538V/cm mun: 510cm^2/(V*s) h100: mu0: 61824cm^2/(V*s) beta: 0.942 E0: 185V/cm h111: mu0: 61215cm^2/(V*s) beta: 0.662 E0: 182V/cm ``` -------------------------------- ### Configure ADL2016ChargeDriftModel via YAML Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Example configuration file for the ADL2016ChargeDriftModel using Bruyneel 2016 parameters. ```yaml model: ADL2016ChargeDriftModel phi110: -45° material: HPGe drift: velocity: model: Bruyneel2016 parameters: e100: mu0: 37165cm^2/(V*s) beta: 0.804 E0: 507.7V/cm mun: -145cm^2/(V*s) escattering: eta0: 0.496 b: 0.0296 Eref: 1200V/cm h100: mu0: 62934cm^2/(V*s) beta: 0.735 E0: 181.9V/cm h111: mu0: 62383cm^2/(V*s) beta: 0.749 E0: 143.9V/cm ``` -------------------------------- ### Install SolidStateDetectors Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/installation.md Use the Julia package manager to add the registered SolidStateDetectors package. ```julia using Pkg; pkg"add SolidStateDetectors" ``` -------------------------------- ### Set JULIA_NUM_THREADS for Bash Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/electric_potential.md To enable multithreading for the electric potential simulation, set the JULIA_NUM_THREADS environment variable in bash before starting Julia. This example sets it to 4 threads. ```bash export JULIA_NUM_THREADS=4 ``` -------------------------------- ### YAML Configuration for CombinedChargeTrappingModel Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Examples of YAML configurations for combining different trapping models in bulk and inactive layers. ```yaml charge_trapping_model: model: Boggs parameters: nσe-1: 1020cm nσh-1: 2040cm model_inactive: ConstantLifetime parameters_inactive: τh: 1μs τe: 1μs ``` ```yaml charge_trapping_model: model: ConstantLifetime parameters: τh: 1ms τe: 1ms model_inactive: ConstantLifetime parameters_inactive: τh: 1μs τe: 1μs ``` -------------------------------- ### Run Simulation on NVIDIA GPU Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/installation.md Example of executing a field calculation on an NVIDIA GPU by specifying the device_array_type. ```julia using CUDA, SolidStateDetectors # *Only* for KernelAbstractions < v0.9: # using CUDAKernels sim = Simulation(SSD_examples[:CGD]) calculate_electric_potential!( sim, device_array_type = CuArray, refinement_limits = [0.2, 0.1, 0.05], depletion_handling = true ) ``` -------------------------------- ### YAML Configuration for ADL2016 Charge Drift Model Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Example YAML configuration for specifying the ADL2016 charge drift model, including material properties, geometry, and detailed drift velocity parameters. This allows for declarative configuration of detector properties. ```yaml detectors: - semiconductor: material: HPGe temperature: 78K charge_drift_model: model: ADL2016ChargeDriftModel phi110: -45deg material: HPGe drift: velocity: model: Bruyneel2016 parameters: e100: mu0: 37165cm^2/(V*s) beta: 0.804 E0: 507.7V/cm mun: -145cm^2/(V*s) escattering: eta0: 0.496 b: 0.0296 Eref: 1200V/cm h100: mu0: 62934cm^2/(V*s) beta: 0.735 E0: 181.9V/cm h111: mu0: 62383cm^2/(V*s) beta: 0.749 E0: 143.9V/cm geometry: tube: r: from: 5mm to: 40mm h: 60mm ``` -------------------------------- ### Configure InactiveLayerChargeDriftModel in YAML Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Example configuration for the InactiveLayerChargeDriftModel within a detector's semiconductor settings. ```yaml detectors: semiconductor: # ... charge_drift_model: model: InactiveLayerChargeDriftModel temperature: 90K bulk_impurity_density: name: constant value: -1e10cm^-3 surface_impurity_density: name: li_diffusion lithium_annealing_temperature: 623K lithium_annealing_time: 18minute doped_contact_id: 2 neutral_impurity_density: name: constant value: 5.6769e15cm^-3 ``` -------------------------------- ### Load Simulation from HDF5 File Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Loads a detector simulation from an HDF5 file using the LegendHDF5IO package. Requires the LegendHDF5IO package to be installed. ```julia using LegendHDF5IO sim_loaded = ssd_read("detector_simulation.h5", Simulation) ``` -------------------------------- ### Minimum Working Example of a True Coaxial Detector Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md This YAML configuration defines a simple true coaxial detector with two contacts, specifying units, grid, medium, and detector properties. ```yaml name: Simple True Coax # optional units: length: mm angle: deg grid: coordinates: cylindrical axes: r: 45 z: from: -40 to: 40 medium: vacuum detectors: - semiconductor: material: HPGe geometry: tube: r: from: 0.5cm to: 4cm h: 6cm contacts: - material: HPGe id: 1 potential: 6000 geometry: tube: r: from: 5 to: 5 h: 60 - material: HPGe id: 2 potential: 0 geometry: tube: r: from: 40 to: 40 h: 60 ``` -------------------------------- ### Save Simulation to HDF5 File Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Saves a detector simulation to an HDF5 file using the LegendHDF5IO package. Requires the LegendHDF5IO package to be installed. ```julia using LegendHDF5IO ssd_write("detector_simulation.h5", sim) ``` -------------------------------- ### Include a list of configuration files Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Provide an array of file paths under the include key to load multiple external files. ```yaml include: - first_file_to_be_included.yaml - second_file_to_be_included.yaml ``` -------------------------------- ### Full Simulation Chain with simulate! Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Execute a complete simulation workflow, including electric potential, electric field, and all weighting potentials, in a single function call. ```julia using SolidStateDetectors using Unitful T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) ``` -------------------------------- ### Configure GPU Support Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/installation.md Load the necessary GPU backend packages to enable hardware acceleration for field calculations. ```julia using CUDA, SolidStateDetectors # *Only* for KernelAbstractions < v0.9: # using CUDAKernels ``` ```julia using AMDGPU, SolidStateDetectors # *Only* for KernelAbstractions < v0.9: # using ROCKernels ``` -------------------------------- ### Initialize Charge Drift Model in Julia Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Instantiate a charge drift model by providing the configuration file path and the simulation precision type. ```julia T = SolidStateDetectors.get_precision_type(sim) # e.g. Float32 charge_drift_model = ADL2016ChargeDriftModel("", T=T) ``` -------------------------------- ### Include a single configuration file Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Use the include key to load a single external YAML or JSON file into the main configuration. ```yaml include: file_to_be_included.yaml ``` -------------------------------- ### Visualize Infinite Boundary Condition Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Demonstrates boundary conditions based on constant ratios between neighboring ticks. ```julia A = deepcopy(P) #hide plot!(A, xticks = (0:10, [L"\"x\$_0\$\"" ; latexstring.("x\$_".*string.(1:9).*"\$"); L"\"x\$_{10}\$\"" ])) #hide plot!(A, -1:0.01:11, x -> ys[end] * (ys[end]/ys[end-1])^(x - xs[end]), color = :red, ls = :dash, label = "") #hide plot!(A, -1:0.01:11, x -> ys[begin] * (ys[begin+1]/ys[begin])^(x - xs[begin]), color = :red, ls = :dash, label = "") #hide scatter!(A, [0,length(xs)+1], [ys[begin]^2/ys[begin+1], ys[end]^2 / ys[end-1]], label = "inf / infinite", color = :red) #hide ``` -------------------------------- ### Visualize Reflecting Boundary Condition Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Demonstrates mirror-symmetry boundary conditions. ```julia A = deepcopy(P) #hide plot!(A, xticks = (0:10, [L"\"x\$_0\$\"" ; latexstring.("x\$_".*string.(1:9).*"\$"); L"\"x\$_{10}\$\"" ])) #hide plot!(A, [minimum(xs) .+ (-1,1)...], [ys[begin+1],ys[begin+1]], arrow = arrow(:both, :closed), label = "", color = :purple) #hide plot!(A, [maximum(xs) .+ (-1,1)...], [ys[end-1],ys[end-1]], arrow = arrow(:both, :closed), label = "", color = :purple) #hide scatter!([0,length(xs)+1], [ys[begin+1], ys[end-1]], label = "reflecting", color = :purple) #hide ``` -------------------------------- ### Apply Rotations to Primitives Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Demonstrates various methods for applying rotations to primitives, including single axis, multiple axes, and matrix definitions. ```yaml tube: r: 1 h: 1 rotation: X: 45° ``` ```yaml tube: r: 1 h: 1 rotation: XZ: [45°, 30°] ``` ```yaml tube: r: 1 h: 1 rotation: M: [1, 0, 0, 0, 0, -1, 0, 1, 0] ``` -------------------------------- ### Visualize Periodic Boundary Condition Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Demonstrates the periodic boundary condition where potential values wrap around. ```julia A = deepcopy(P) #hide plot!(A, xticks = (0:10, [L"\"x\$_0\$\"" ; latexstring.("x\$_".*string.(1:9).*"\$"); L"\"x\$_{10}\$\"" ])) #hide plot!(A, [extrema(xs) .+ (0,1)...], [ys[begin],ys[begin]], arrow = arrow(:both, :closed), label = "", color = :orange) #hide plot!(A, [reverse(extrema(xs)) .- (0,1)...], [ys[end],ys[end]], arrow = arrow(:both, :closed), label = "", color = :orange) #hide scatter!(A, [0,length(xs)+1], [ys[end], ys[begin]], label = "periodic", color = :orange) #hide ``` -------------------------------- ### Get Electron and Hole Contributions Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Retrieve the separate contributions of electrons and holes to the induced signal for a specific contact. This can help in analyzing charge carrier behavior. ```julia # Get electron and hole contributions separately contact_id = 1 contributions = get_electron_and_hole_contribution(evt, sim, contact_id) # contributions.electron_contribution # contributions.hole_contribution ``` -------------------------------- ### Create and Simulate Single-Site Event Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Generate a single-site event with a specified position and energy, then simulate its drift and signal generation within the detector. Requires `SolidStateDetectors` and `Unitful` packages. ```julia using SolidStateDetectors using Unitful T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) simulate!(sim) # Create single-site event starting_position = CylindricalPoint{T}(0.020, deg2rad(10), 0.015) energy = 1460u"keV" evt = Event(starting_position, energy) ``` -------------------------------- ### Initialize CSG and Plotting Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Sets up the necessary environment for Constructive Solid Geometry operations and plotting within SolidStateDetectors.jl. ```julia using SolidStateDetectors import SolidStateDetectors.ConstructiveSolidGeometry as CSG using Plots T = Float64; ``` -------------------------------- ### Apply Initial State and Plot Electric Potential Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/electric_potential.md Applies the initial state for electric potential calculation and plots the effective charge and dielectric constant distributions. Ensure SolidStateDetectors and Plots are imported. ```julia using SolidStateDetectors using Plots sim = Simulation(SSD_examples[:InvertedCoax]) apply_initial_state!(sim, ElectricPotential) plot( plot(sim.q_eff_imp), plot(sim.ϵ_r) ) ``` -------------------------------- ### Simulate Underdepleted Detector Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Demonstrates creating a deep copy of a simulation, adjusting contact potential, and calculating electric potential with depletion handling enabled. ```julia # Create a copy for underdepleted simulation sim_undep = deepcopy(sim) # Modify the potential of contact 2 (e.g., mantle) to a lower voltage sim_undep.detector = SolidStateDetector(sim_undep.detector, contact_id = 2, contact_potential = 500 # V (reduced from original) ) # Calculate with depletion handling calculate_electric_potential!(sim_undep, depletion_handling = true, refinement_limits = [0.2, 0.1, 0.05] ) # Check depletion status is_depleted(sim_undep.point_types) # Returns false for underdepleted get_active_volume(sim_undep.point_types) # Reduced active volume ``` -------------------------------- ### Load Custom ADL Parameters from File Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Load custom charge drift parameters, specifically for the ADL2016 model, from a YAML configuration file. This allows for fine-tuning drift behavior based on experimental data or specific material properties. ```julia using SolidStateDetectors T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) # Load custom ADL parameters from file charge_drift_model = ADL2016ChargeDriftModel( "path/to/drift_velocity_config.yaml", T = T, temperature = 100u"K" ) sim.detector = SolidStateDetector(sim.detector, charge_drift_model) ``` -------------------------------- ### Load Simulation with JLD2 Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/IO.md Load simulation results from a JLD file using FileIO.load. Specify the file path and the key under which the simulation was saved. ```julia using FileIO sim = FileIO.load(".jld", "Simulation") ``` -------------------------------- ### Plotting Detector Components Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/plotting.md Demonstrates how to initialize a plot with units and overlay specific detector components using different seriestypes. ```julia plot(u"cm", u"cm", u"cm") plot!(det.semiconductor, st = :samplesurface, n_samples = 100, markersize = 2, camera = (40, 55), size = (500, 500)) plot!(det.contacts[1], st = :mesh3d, linewidth = 0.5, fillcolor = :white) plot!(det.contacts[2], st = :wireframe, n_vert_lines = 5) ``` -------------------------------- ### Configure global medium and surroundings Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Define the global medium and external passive objects in the configuration root. ```yaml name: # ... # optional units: #... grid: #... medium: vacuum detectors: # ... ``` ```yaml name: # ... # optional units: #... grid: #... medium: vacuum detectors: - semiconductor: # ... contacts: - # ... - # ... passives: - # ... - # ... surroundings: - #... - #... ``` -------------------------------- ### Display Ellipsoid_full_sphere Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a full sphere primitive. This shows how a sphere is defined. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Ellipsoid_full_sphere.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Visualize Fixed Boundary Condition Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/grids.md Demonstrates setting potential beyond the boundary to the boundary value. ```julia A = deepcopy(P) #hide plot!(A, xticks = (0:10, [L"\"x\$_0\$\"" ; latexstring.("x\$_".*string.(1:9).*"\$"); L"\"x\$_{10}\$\"" ])) #hide plot!(A, [minimum(xs) .+ (-1,0)...], [ys[begin],ys[begin]], arrow = arrow(:both, :closed), label = "", color = :green) #hide plot!(A, [maximum(xs) .+ (1,0)...], [ys[end],ys[end]], arrow = arrow(:both, :closed), label = "", color = :green) #hide scatter!(A, [0,length(xs)+1], [ys[begin], ys[end]], label = "fix / fixed", color = :green) #hide ``` -------------------------------- ### Run Full Simulation Chain Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Execute the complete simulation process for a detector. This includes calculating electric fields, potentials, and other relevant physical quantities. Ensure all necessary parameters are set before running. ```julia simulate!(sim, convergence_limit = 1e-7, refinement_limits = [0.2, 0.1, 0.05], depletion_handling = true, max_n_iterations = 50000, verbose = true ) ``` -------------------------------- ### Simulate and Plot Event Drift Paths Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/plotting.md Simulates an event and plots its charge drift paths. Requires an initialized `Event` and simulation object. ```julia evt = Event([CartesianPoint{T}(0.01,0.01,0.075)], [2u"MeV"]) simulate!(evt, sim) plot(sim.detector, size = (500,500), label = "") plot!(evt.drift_paths) ``` -------------------------------- ### Create and Simulate Multi-Site Event Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Generate a multi-site event by defining multiple positions and energies, then simulate its drift and signal generation. This allows for modeling complex interactions within the detector. ```julia using SolidStateDetectors using Unitful T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) simulate!(sim) # Create multi-site event positions = [ CylindricalPoint{T}(0.020, deg2rad(10), 0.015), CylindricalPoint{T}(0.015, deg2rad(20), 0.045), CylindricalPoint{T}(0.022, deg2rad(35), 0.025) ] energies = T[1460, 609, 1000] * u"keV" evt = Event(positions, energies) ``` -------------------------------- ### Display Torus Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a Torus primitive. This allows inspection of its definition. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Torus.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Configure Boggs Charge Trapping Model (YAML) Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Apply the Boggs charge trapping model in a configuration file by specifying 'Boggs' for the model and providing parameters like inverse trapping products (nσe-1, nσh-1) and optionally temperature. ```yaml detectors: - semiconductor: material: #... geometry: #... charge_trapping_model: model: Boggs parameters: nσe-1: 1020cm nσh-1: 2040cm temperature: 78K ``` ```yaml detectors: - semiconductor: material: #... geometry: #... charge_trapping_model: model: Boggs parameters: nσe: 0.001cm^-1 nσh: 0.0005cm^-1 temperature: 78K ``` -------------------------------- ### Display Cone Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a Cone primitive. This configuration defines a cone with a varying radius. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Cone.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Create NBodyChargeCloud with Regular Sphere Distribution Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Creates an NBodyChargeCloud using an algorithm for charges equally distributed on the surface of a regular sphere. This method is preferred for more than approximately 50 charges. ```julia center = CartesianPoint{T}(0,0,0) energy = 1460u"keV" nbcc = NBodyChargeCloud(center, energy, 100) plot(nbcc) plot(nbcc, color = :red, size = (500,500), xlims = (-0.0012, 0.0012), ylims = (-0.0012,0.0012), zlims = (-0.0012,0.0012)) #hide ``` -------------------------------- ### Apply custom model to simulation Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Instantiate the custom model and assign it to the detector simulation. ```julia T = SolidStateDetectors.get_precision_type(sim) # e.g. Float32 charge_drift_model = CustomChargeDriftModel{T}() sim.detector = SolidStateDetector(sim.detector, charge_drift_model) ``` -------------------------------- ### Load Simulation from JLD2 File Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Loads a previously saved detector simulation from a JLD2 file. Requires the FileIO package. ```julia using SolidStateDetectors using FileIO # Load simulation sim_loaded = FileIO.load("detector_simulation.jld2", "Simulation") ``` -------------------------------- ### Display Box Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a Box primitive. This allows inspection of how a Box is defined. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Box.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Simulate combined diffusion and self-repulsion in Julia Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Use this configuration to simulate realistic charge cloud behavior. Note that enabling these effects significantly increases simulation time. ```julia center = CartesianPoint{T}(0,0,0) energy = 1460u"keV" nbcc = NBodyChargeCloud(center, energy, 100) evt = Event(nbcc) simulate!(evt, sim, diffusion = true, self_repulsion = true, end_drift_when_no_field = true) ``` -------------------------------- ### Compare 3D Plot Styles for Semiconductor Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/plotting.md Visualizes the semiconductor component specifically using different seriestypes. ```julia plot( plot(det.semiconductor, seriestype = :csg, title = ":csg"), plot(det.semiconductor, seriestype = :wireframe, title = ":wireframe"), plot(det.semiconductor, seriestype = :mesh3d, title = ":mesh3d"), plot(det.semiconductor, seriestype = :samplesurface, title = ":samplesurface", markersize = 1, n_samples = 50), layout = (1,4), size = (800,200), legend = false, ticks = false, guide = "", zlims = (-0.005,0.1), axis = false ) ``` -------------------------------- ### Initialize ADL2016ChargeDriftModel in Julia Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Initialize the ADL2016ChargeDriftModel with a configuration file path, precision type, and temperature. This model is used to update the detector's charge drift properties. ```julia T = SolidStateDetectors.get_precision_type(sim) # e.g. Float32 charge_drift_model = ADL2016ChargeDriftModel("", T = T, temperature = 100u"K") sim.detector = SolidStateDetector(sim.detector, charge_drift_model) ``` -------------------------------- ### Display Polycone Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a Polycone primitive. This allows inspection of its definition. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Polycone.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Display Cone_tube Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a Cone_tube primitive. This shows the definition of a tube-like cone. ```julia cfn = joinpath(path_to_example_primitives_config_files, "Cone_tube.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Simulate Event with Custom Parameters Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Simulate an event using specific parameters for time step, maximum steps, diffusion, self-repulsion, and signal unit. This provides fine-grained control over the simulation process. ```julia # Simulate the event (drift + signal generation) simulate!(evt, sim, Δt = 5u"ns", max_nsteps = 1000, diffusion = false, self_repulsion = false, signal_unit = u"keV" ) ``` -------------------------------- ### Configure Temperature Dependence in YAML Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Enable the M.A. Omar and L. Reggiani parametrization for temperature dependence in charge drift configuration files by adding the 'temperature_dependence' field. ```yaml temperature_dependence: reference_temperature: 77K model: Omar1987 parameters: e: p: 1.68 theta: 200K h: p: 2.4 theta: 200K ``` -------------------------------- ### Display RegularPrism_hexagon Primitive Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Prints the content of the YAML configuration file for a hexagonal prism. This shows how a hexagonal prism is defined. ```julia cfn = joinpath(path_to_example_primitives_config_files, "RegularPrism_hexagon.yaml") print(open(f -> read(f, String), cfn)) ``` -------------------------------- ### Generate Automated Documentation Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/api.md Configures the autodocs block to document constants, types, and functions from the specified modules. ```julia Modules = [SolidStateDetectors, SolidStateDetectors.ConstructiveSolidGeometry] Order = [:constant, :type, :function] ``` -------------------------------- ### Configure Constant Lifetime Charge Trapping Model Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Applies a constant lifetime charge trapping model. Requires specifying the electron and hole lifetimes. ```julia parameters = Dict("parameters" => Dict( "τe" => 1u"ms", # electron lifetime "τh" => 1u"ms" # hole lifetime )) sim.detector = SolidStateDetector(sim.detector, ConstantLifetimeChargeTrappingModel{T}(parameters)) ``` -------------------------------- ### Configure Constant Lifetime Charge Trapping Model (YAML) Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Configure the ConstantLifetime charge trapping model in a YAML file by setting the model to 'ConstantLifetime' and providing parameters for hole (τh) and electron (τe) lifetimes. ```yaml detectors: - semiconductor: material: #... geometry: #... charge_trapping_model: model: ConstantLifetime parameters: τh: 1ms τe: 1ms ``` -------------------------------- ### Compare 3D Plot Styles Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/plotting.md Demonstrates the four available 3D seriestypes for detector visualization. ```julia plot( plot(det, seriestype = :csg, title = ":csg"), plot(det, seriestype = :wireframe, title = ":wireframe"), plot(det, seriestype = :mesh3d, title = ":mesh3d"), plot(det, seriestype = :samplesurface, title = ":samplesurface", markersize = 1, n_samples = 50), layout = (1,4), size = (800,200), legend = false, ticks = false, guide = "", zlims = (-0.005,0.1), axis = false ) ``` -------------------------------- ### Index Functions Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/api.md Generates an index for functions in the documentation. ```julia Order = [:function] ``` -------------------------------- ### Detector Configuration File Structure (YAML) Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Define detector properties, units, grid settings, and geometry using a YAML file. Supports Cartesian and cylindrical coordinates. ```yaml name: Simple True Coax units: length: mm angle: deg grid: coordinates: cylindrical axes: r: 45 phi: from: 0 to: 0 boundaries: periodic z: from: -40 to: 40 medium: vacuum detectors: - semiconductor: material: HPGe temperature: 78 impurity_density: name: linear offset: 1e10cm^-3 gradient: z: 1e9cm^-4 geometry: tube: r: from: 5mm to: 40mm h: 60mm contacts: - id: 1 potential: 5000V geometry: tube: r: from: 5 to: 5 h: 60 - id: 2 potential: 0 geometry: tube: r: from: 40 to: 40 h: 60 ``` -------------------------------- ### Create NBodyChargeCloud with Platonic Solids Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Defines an NBodyChargeCloud with a center point charge surrounded by shells of point charges on the vertices of platonic solids. Useful for smaller numbers of charges where symmetry is desired. ```julia using SolidStateDetectors #hide using Unitful #hide using Plots #hide T = Float64 #hide center = CartesianPoint{T}(0,0,0) energy = 1460u"keV" nbcc = NBodyChargeCloud(center, energy) plot(nbcc) plot(nbcc, color = :red, size = (500,500), xlims = (-0.0012, 0.0012), ylims = (-0.0012,0.0012), zlims = (-0.0012,0.0012)) #hide ``` -------------------------------- ### Simulate Event with N-Body Charge Cloud Effects Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Simulates an event using an N-body charge cloud, enabling diffusion and self-repulsion effects. Requires specifying the time step and drift behavior. ```julia evt = Event(nbcc) # Simulate with group effects simulate!(evt, sim, diffusion = true, # Enable thermal diffusion self_repulsion = true, # Enable Coulomb self-repulsion Δt = 1u"ns", end_drift_when_no_field = true ) plot(sim.detector) plot!(evt.drift_paths) ``` -------------------------------- ### Configure Phi Axis with Mixed Boundaries Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Use for systems with mixed symmetries, e.g., 60° periodicity with mirror symmetry at 30°. Allows different boundary conditions for the left and right ends. ```yaml grid: coordinates: cylindrical axes: r: #... phi: from: 0° to: 30° boundaries: left: periodic right: reflecting z: #... ``` -------------------------------- ### Index Types Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/api.md Generates an index for types in the documentation. ```julia Order = [:type] ``` -------------------------------- ### Configure Linear Exponential Boule Impurity Density Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/electric_potential.md Sets up an impurity density model based on boule coordinates using a linear plus exponential profile. ```yaml impurity_density: name: linear_exponential_boule a: -1e10cm^-3 b: -1e9cm^-4 n: -2e9cm^-3 l: 5cm m: 3cm det_z0: 120cm ``` -------------------------------- ### Configure Boggs Charge Trapping Model Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Applies the Boggs charge trapping model to a detector simulation. Requires specifying inverse trapping products for electrons and holes, and the temperature. ```julia parameters = Dict("parameters" => Dict( "nσe-1" => 1000u"cm", # inverse trapping product for electrons "nσh-1" => 500u"cm", # inverse trapping product for holes "temperature" => 78u"K" )) sim.detector = SolidStateDetector(sim.detector, BoggsChargeTrappingModel{T}(parameters)) ``` -------------------------------- ### Create N-Body Charge Cloud with Platonic Solids Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Generates an N-body charge cloud using platonic solids for shell structure, suitable for fewer than 50 charges. Requires specifying the center and energy deposition. ```julia center = CartesianPoint{T}(0.02, 0.01, 0.05) energy = 1460u"keV" # Using platonic solids for shell structure (< 50 charges) nbcc = NBodyChargeCloud(center, energy) ``` -------------------------------- ### Calculate Weighting Potentials on GPU Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Calculates weighting potentials for each contact on the GPU. Requires specifying the device array type and refinement limits. ```julia using CUDA # or AMDGPU for AMD GPUs using SolidStateDetectors T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) # Calculate weighting potentials on GPU for contact in sim.detector.contacts calculate_weighting_potential!(sim, contact.id, device_array_type = CuArray, refinement_limits = [0.2, 0.1, 0.05] ) end ``` -------------------------------- ### Index Constants Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/api.md Generates an index for constants in the documentation. ```julia Order = [:constant] ``` -------------------------------- ### Load and Plot Cone_tube Primitive Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Loads a Cone_tube primitive from a YAML configuration file and plots it. This primitive represents a standard tube shape. ```julia cone = CSG.Geometry(T, cfn) plot(cone) ``` -------------------------------- ### Calculate Weighting Potentials Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Compute weighting potentials for each contact using the Shockley-Ramo theorem. Access and plot individual potentials. ```julia using SolidStateDetectors sim = Simulation{Float32}(SSD_examples[:InvertedCoax]) calculate_electric_potential!(sim, refinement_limits = [0.2, 0.1, 0.05]) # Calculate weighting potential for each contact for contact in sim.detector.contacts calculate_weighting_potential!(sim, contact.id, refinement_limits = [0.2, 0.1, 0.05], verbose = false ) end # Access weighting potentials wp_contact1 = sim.weighting_potentials[1] wp_contact2 = sim.weighting_potentials[2] # Plot weighting potential plot(sim.weighting_potentials[1]) plot!(sim.detector, st = :slice, φ = 0) ``` -------------------------------- ### Combine Transformations Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Shows the order of operations when both rotation and translation are applied to a primitive. ```yaml tube: r: 1 h: 1 rotation: X: 45° origin: z: 1cm ``` -------------------------------- ### Load and Plot Ellipsoid Primitive Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Loads a full sphere primitive from a YAML configuration file and plots it. This represents a spherical geometry. ```julia ellipsoid = CSG.Geometry(T, cfn) plot(ellipsoid) ``` -------------------------------- ### Defining Custom Units in Configuration Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Specify custom units for length, angle, potential, and temperature. Values will be parsed according to these definitions. ```yaml units: length: mm angle: deg ``` -------------------------------- ### Write Simulation to HDF5 Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/IO.md Write simulation results to an HDF5 file using the ssd_write function. This requires SolidStateDetectors and LegendHDF5IO to be used. ```julia using SolidStateDetectors using LegendHDF5IO # ... ssd_write(".h5", sim) ``` -------------------------------- ### Implement velocity transformation methods Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/charge_drift.md Define getVe and getVh methods to transform electric field vectors into velocity vectors. ```julia using StaticArrays function SolidStateDetectors.getVe(fv::SVector{3, T}, cdm::CustomChargeDriftModel, current_pos::CartesianPoint{T})::SVector{3, T} where {T <: SSDFloat} # arbitrary transformation of fv, optionally position dependent return -fv end function SolidStateDetectors.getVh(fv::SVector{3, T}, cdm::CustomChargeDriftModel, current_pos::CartesianPoint{T})::SVector{3, T} where {T <: SSDFloat} # arbitrary transformation of fv, optionally position dependent return fv end ``` -------------------------------- ### Create N-Body Charge Cloud with Equally Distributed Points Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Generates an N-body charge cloud with points equally distributed on a sphere, suitable for more than 50 charges. Requires specifying the center, energy deposition, and number of points. ```julia center = CartesianPoint{T}(0.02, 0.01, 0.05) energy = 1460u"keV" # Using equally distributed points on sphere (> 50 charges) nbcc = NBodyChargeCloud(center, energy, 100) ``` -------------------------------- ### Load and Plot Torus Primitive Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/csg.md Loads a Torus primitive from a YAML configuration file and plots it. This primitive represents a donut-like shape. ```julia torus = CSG.Geometry(T, cfn) plot(torus, zlims = [-6,6], camera = (40, 55)) ``` -------------------------------- ### Read Simulation from HDF5 Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/IO.md Read simulation results from an HDF5 file using the ssd_read function. Specify the file path and the expected type, such as Simulation. ```julia using SolidStateDetectors using LegendHDF5IO ssd_read(".h5", Simulation) ``` -------------------------------- ### Define passive objects and charged surfaces Source: https://github.com/juliaphysics/solidstatedetectors.jl/blob/main/docs/src/man/config_files.md Use the passives array to define passive components like cryostats or passivated surfaces, including optional temperature and charge density settings. ```yaml passives: - name: Passivated Surface material: HPGe charge_density: # ... geometry: # ... - name: Cryostat id: 3 potential: 0 temperature: 293K material: Al geometry: # ... ``` -------------------------------- ### Drift Charges Separately Source: https://context7.com/juliaphysics/solidstatedetectors.jl/llms.txt Perform charge drift as a distinct step in the simulation process. This allows for intermediate analysis or modification of drift paths before signal generation. Diffusion can be enabled. ```julia using SolidStateDetectors using Unitful T = Float32 sim = Simulation{T}(SSD_examples[:InvertedCoax]) simulate!(sim) # Create event positions = [CartesianPoint{T}(0.02, 0.01, 0.05)] energies = [1460u"keV"] evt = Event(positions, energies) # Step 1: Drift charges drift_charges!(evt, sim, Δt = 5u"ns", max_nsteps = 1000, diffusion = true, self_repulsion = false, verbose = true ) ```