SolidStateDetectors.jl

repository·main·Indexed 41 days ago

https://github.com/juliaphysics/solidstatedetectors.jl

A high-performance Julia package for the fast 2D and 3D simulation of solid-state detectors. Part of the JuliaPhysics ecosystem, it provides tools for calculating Maxwell capacitance matrices, simulating charge drift using models like ADL2016 and InactiveLayer, and implementing charge trapping models such as Boggs and ConstantLifetime. Requires Julia >= v1.11.

Tokens
17.5K
Snippets
57
Records
75
Agent score
49%

What's inside SolidStateDetectors.jl

  1. Temperature validation in charge trapping models

    main

    Temperature handling for charge trapping models follows these rules:

    1. Preference: It is best to define temperature in semiconductor.temperature. This value is automatically passed to the trapping model.
    2. Redundancy: You can also specify temperature inside the parameters block or at the top level of the charge_trapping_model config. If both semiconductor.temperature and a model-specific temperature are provided, they must match, or an error is raised.
    3. Defaults: If semiconductor.temperature is not defined, a material-specific default is used (77 K for High Purity Germanium, 293 K otherwise) and a warning is issued. Even if a temperature is specified in parameters, the semiconductor temperature is resolved first.
  2. Construct geometries using Constructive Solid Geometry (CSG)

    main

    Complex geometries in SolidStateDetectors.jl are built using Constructive Solid Geometry (CSG). This involves combining simple Volume Primitives (like Box, Tube, or Sphere) using Boolean Operators (union, difference, intersection) and applying Transformations (rotation and translation).

    Geometries can be defined via YAML configuration files and loaded into the Julia environment using CSG.Geometry.

    using SolidStateDetectors
    import SolidStateDetectors.ConstructiveSolidGeometry as CSG
    
    T = Float64
    cfn = "path/to/your/geometry.yaml"
    geometry = CSG.Geometry(T, cfn)
    plot(geometry)
  3. Understanding Charge Drift in Solid State Detectors

    main

    In solid state detectors, charged particles do not undergo ballistic transport (continuous acceleration) as they would in a vacuum. Instead, scattering with the material matter limits their acceleration, resulting in a constant drift velocity $v_{d}$ determined by the mobility $\mu$ and the electric field strength $E$:

    $$v_{d} = \mu E$$

    Because scattering can cause trajectories to deviate from electric field lines (for example, due to crystal axis orientation), the relationship between the electric field and drift velocity is expressed using a 3x3 mobility tensor $\mu_{ij}$:

    $$v_{i} = \mu_{ij} \cdot E_{j}$$

    Mobility is not a constant; it varies based on the material, temperature, impurity density, and the strength of the electric field.

  4. Understand the concept of Weighting Potentials

    main

    A weighting potential $\Phi_i^w$ is a theoretical potential that describes the fraction of a charge at position $\vec{r}$ that is 'seen' by a specific contact $C_i$.

    • A value of 0 means the charge is not seen by the electrode.
    • A value of 1 means the charge is collected by the electrode.

    According to the Shockley-Ramo theorem, the net charge $Q_i$ induced on an electrode $C_i$ by electrons and holes (with absolute charge $Q$) is calculated as:

    $$Q_i = Q \left( \sum_{\text{holes}} \Phi_i^w(\vec{r}h) - \sum{\text{electrons}} \Phi_i^w(\vec{r}_e) \right)$$

    Mathematically, the weighting potential is defined by the following Poisson equation (where $\epsilon_r$ is the dielectric distribution):

    $$\nabla \left( \epsilon_r(\vec{r}) \nabla \Phi_i^w(\vec{r})\right) = 0$$

    With boundary conditions at the contacts $C_j$: $$\Phi_i^w(\vec{r})\vert_{C_j} = \begin{cases} 1, & \text{if } i = j \ 0, & \text{if } i \neq j \end{cases}$$

  5. Configure DiscreteAxis and boundary conditions

    main

    A SolidStateDetectors.DiscreteAxis defines a single dimension of a grid. It stores:

    • ax.interval: The range of the axis (can be :closed or :open).
    • ax.ticks: The discrete points along the axis (can be non-uniformly spaced for adaptive refinement).
    • Boundary conditions: Determines how potential is handled at the edges of the world.

    Available boundary conditions for an axis:

    • periodic: Assumes potential is periodic (ϕ(x0) = ϕ(xN) and ϕ(xN+1) = ϕ(x1)).
    • reflecting: Assumes mirror-symmetry (ϕ(x0) = ϕ(x2) and ϕ(xN+1) = ϕ(xN-1)).
    • fixed (or fix): Sets potential beyond the boundary to the boundary value (ϕ(x0) = ϕ(x1) and ϕ(xN+1) = ϕ(xN)).
    • infinite (or inf): Assumes a constant ratio between neighboring ticks (ϕ(x0)/ϕ(x1) = ϕ(x1)/ϕ(x2)).
  6. Define the simulation grid and coordinate systems

    main

    The grid section defines the finite world where calculations occur. You must specify the coordinates type and the dimensions of the axes.

    Supported Coordinate Systems:

    • cartesian: Requires axes x, y, and z.
    • cylindrical: Requires axes r, phi, and z.

    Axis Dimensions: Each axis is defined by a from and to value.

    grid:
      coordinates: cylindrical
      axes:
        r: 45
        z:
          from: -40
          to: 40
  7. Configure grid boundary handling and symmetries

    main

    You can use boundaries within the axes field to implement symmetries and reduce calculation volume.

    Linear Axes (x, y, z):

    • infinite, periodic, reflecting, or fixed.

    Radial Axes (r):

    • Left boundary: Defaults to r0.
    • Right boundary: Can be infinite, reflecting, or fixed.

    Angular Axes (phi):

    • reflecting or periodic (defaults to periodic for both edges).

    Symmetry Examples:

    • 2D $\varphi$-symmetric: Set phi range from 0 to 0 with periodic boundaries.
    • $\varphi$-periodic fraction: Set phi to a specific interval (e.g., 0° to 120°) with periodic boundaries.
    • Mirror symmetry: Use left: periodic and right: reflecting on an angular axis.
    grid:
      coordinates: cylindrical
      axes:
        r: # ...
        phi:
          from: 0°
          to: 30°
          boundaries:
            left: periodic
            right: reflecting
        z: # ...
  8. Understand Grid types and structures

    main

    SolidStateDetectors.jl uses a 3-dimensional grid to calculate electric potential via successive over-relaxation (SOR). The 'world' (the simulation volume) is divided into discrete points called a grid::Grid.

    You can choose between two primary grid geometries:

    • CartesianGrid: Uses three axes: x, y, and z.
    • CylindricalGrid: Uses three axes: r, φ, and z.

    A Grid is defined by its grid.axes, where each axis is a SolidStateDetectors.DiscreteAxis containing a specific number of discrete points (ticks) within a defined interval.

  9. Configure 3D detector plot styles

    main

    The seriestype (or st) keyword controls the 3D rendering style of the detector geometry:

    • :csg (default): Plots a wireframe on top of a mesh. Best for geometries consisting of unions of primitives.
    • :wireframe: Fast plotting of the wireframe only.
    • :mesh3d: Fast plotting of the mesh only.
    • :samplesurface: A marker-based style. Recommended for geometries involving differences or intersections. Use n_samples (e.g., > 100) and markersize to increase fidelity.

    Note: For :csg, :wireframe, and :mesh3d, if the geometry contains differences, the resulting negative geometries may appear with thinner lines or semi-transparent white faces.

    # Comparing different 3D styles
    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)
    )
  10. Use Boolean operators to combine geometries

    main

    Boolean operators allow you to combine multiple geometries into a single complex object via YAML configuration:

    1. union (A || B): The set of points in at least one of the objects.
      union:
        - tube: { r: 2, h: 1 }
        - tube: { r: 1, h: 1.5, origin: { z: 0.5 } }
    2. difference (A && !B): The set of points in A but not in B. The first entry is the base geometry; subsequent entries are subtracted from it. Note: To ensure clean surfaces, make the subtracted object B slightly larger than A.
      difference:
        - tube: { r: 2, h: 1 }
        - tube: { r: 1, h: 1.1 }
    3. intersection (A && B): The set of points present in all provided geometries.
      intersection:
        - tube: { r: 2, h: 1 }
        - tube: { r: 1, h: 1.5, origin: { z: 0.5 } }
  11. Install and setup plotting with Plots.jl

    main

    To plot geometries or simulation results in SolidStateDetectors.jl, you must load the Plots.jl package. The plotting system integrates with Unitful.jl to handle physical dimensions on axes.

    using Plots
    using SolidStateDetectors
    using Unitful
    
    # Example setup
    T = Float32
    sim = Simulation{T}(SSD_examples[:InvertedCoax]);
    simulate!(sim, convergence_limit = 1e-6, refinement_limits = [0.2, 0.1, 0.05, 0.01]);