Skip to content

Commit

Permalink
Merge pull request #66 from apearsonn/dev
Browse files Browse the repository at this point in the history
Implement active volume calculation for cracks
  • Loading branch information
fhagemann authored Sep 19, 2024
2 parents 7f2a917 + 8fa3ba8 commit d3c7ea5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions src/active_volume.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,38 @@
@inline get_outer_taper_volume(x, y, h, r) = π * (r^2 * h - (r - x)^2 * h) - get_inner_taper_volume(x, y, h, r)

function get_extra_volume(geometry::PropDict, ::Val{:crack}, fccd::T) where {T <: AbstractFloat}

Check warning on line 10 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L10

Added line #L10 was not covered by tests
@warn "Active volume calculations for detectors with cracks are not implemented yet"
return zero(T)
# Find a picture of the definition of crack here:
# https://github.com/legend-exp/legend-metadata/blob/archived/hardware/detectors/detector-metadata_5.pdf
r = geometry.radius_in_mm - fccd
H = geometry.height_in_mm - 2*fccd
alpha = geometry.extra.crack.angle_in_deg
p0 = geometry.extra.crack.radius_in_mm + fccd * (secd(alpha) - tand(alpha) - 1)
return if iszero(alpha)

Check warning on line 17 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L13-L17

Added lines #L13 - L17 were not covered by tests
# Vertical crack
(r^2 * acos(1 - p0/r) - sqrt(2r*p0 - p0^2) * (r - p0)) * H

Check warning on line 19 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L19

Added line #L19 was not covered by tests
else
# Inclined crack
t = max(p0 - H * tand(alpha), p0 * 0)
int11 = (1 - t/r) * acos(1 - t/r) - sqrt(1 - (1 - t/r)^2)
int12 = (1 - p0/r) * acos(1 - p0/r) - sqrt(1 - (1 - p0/r)^2)
-cotd(alpha) * (r^3 * (int12 - int11) + ((2*r*p0 - p0^2)^(3/2) - (2*r*t - t^2)^(3/2))/ 3)

Check warning on line 25 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L22-L25

Added lines #L22 - L25 were not covered by tests
end
end

function get_extra_volume(geometry::PropDict, ::Val{:topgroove}, fccd::AbstractFloat)

Check warning on line 29 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L29

Added line #L29 was not covered by tests
r = geometry.extra.topgroove.radius_in_mm
d = geometry.extra.topgroove.depth_in_mm
return π * r^2 * d
# Find a picture of the definition of topgroove here:
# https://github.com/legend-exp/legend-metadata/blob/archived/hardware/detectors/detector-metadata_4.pdf
rb = geometry.borehole.radius_in_mm
db = geometry.borehole.radius_in_mm
rg = geometry.extra.topgroove.radius_in_mm
dg = geometry.extra.topgroove.depth_in_mm
db <= dg && @warn "The depth of the borehole ($(db)mm) should be bigger than the depth of the topgroove ($(dg)mm)."
return π * ((rg + fccd)^2 - (rb + fccd)^2) * dg

Check warning on line 37 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L32-L37

Added lines #L32 - L37 were not covered by tests
end

function get_extra_volume(geometry::PropDict, ::Val{:bottom_cylinder}, fccd::AbstractFloat)

Check warning on line 40 in src/active_volume.jl

View check run for this annotation

Codecov / codecov/patch

src/active_volume.jl#L40

Added line #L40 was not covered by tests
# Find a picture of the definition of bottom_cylinder here:
# https://github.com/legend-exp/legend-metadata/blob/archived/hardware/detectors/detector-metadata_6.pdf
r = geometry.extra.bottom_cylinder.radius_in_mm - fccd
h = geometry.extra.bottom_cylinder.height_in_mm - fccd
t = geometry.extra.bottom_cylinder.transition_in_mm
Expand Down
2 changes: 1 addition & 1 deletion src/legend_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function channelinfo(data::LegendData, sel::AnyValiditySelection; system::Symbol
else
fccds[first(keys(fccds))].value
end
active_volume::Unitful.Volume{<:Float64} = if haskey(diodmap, k) get_active_volume(diodmap[k], 0.0) else Float64(NaN) * u"cm^3" end
active_volume::Unitful.Volume{<:Float64} = if haskey(diodmap, k) get_active_volume(diodmap[k], fccd) else Float64(NaN) * u"cm^3" end
c = merge(c, (; cc4, cc4ch, daqcrate, daqcard, hvcard, hvch, enrichment, mass, total_volume, active_volume))
end

Expand Down

0 comments on commit d3c7ea5

Please sign in to comment.