Introduction
This section is provided for developer who are interested in extending the functionality of the GeoEfficiency package or just make use of some of its functionality. this software is licensed under the MIT license.
Configuration
The package contain many parameters that can be set within the program sourcecode. they can be found in the source file Config.jl
| parameter | description | default value |
|---|---|---|
| dataFolder | name of the root directory | "GeoEfficiency" |
| dataDir | root directory | joinpath(homedir(), dataFolder) |
| integrate | use the package QuadGK to perform integration | begin using QuadGK; QuadGK.quadgk; end |
| relativeError | 1.0E-4 | |
| absoluteError | eps(1.0) | |
| resultsFolder | name of the result directory inside the root directory | "results" |
| max_display | define the default for maximum number of entries shown in the console in batch mode | 20 see max_batch |
Error System
GeoEfficiency.GeoException — Type.custom abstract Exception that is the parent of all Exception in the GeoEfficiency package
GeoEfficiency.InValidDetectorDim — Type.custom Exception indicating invalid radiation detector dimensions
GeoEfficiency.@validateDetector — Macro.@validateDetector cond [text]throw an InValidDetectorDim if cond is false. Message text is optionally displayed upon validation failure.
Examples
julia> @validateDetector iseven(3) "3 is an odd number!"
ERROR: InValidDetectorDim: 3 is an odd number!
julia> @validateDetector isodd(3) "What even are numbers?"GeoEfficiency.InValidGeometry — Type.custom Exception indicating a not valid source to detector geometry
GeoEfficiency.@inValidGeometry — Macro.@inValidGeometry [msg]custom macro to throw NotImplementedError Exception.
custom Exception indicating a source-to-detector geometry which may be valid but not implemented yet
GeoEfficiency.@notImplementedError — Macro.@notImplementedError [msg]custom macro to throw NotImplementedError Exception.
Console Input
Julia language is quite reach language but it seems a good idea thought to collect repeated tasks involving input from console in compact and customized to the need function. this section provide two essential functions to deal with inputs from the console. the first:
GeoEfficiency.input — Function.UnExported
input(prompt::AbstractString = "?: ", incolor::Symbol = :green)return a string represent the user respond delimited by new line excluding the new line. prompt the user with the massage prompt defaults to ?. wait until the user type its respond and press return. incolor specify the prompt text color, default to $:green$ may take any of the values :black, :blue, :cyan, :green, :light_black, :light_blue, :light_cyan, :light_green, :light_magenta, :light_red, :light_yellow, :magenta, :red, :white, or :yellow.
The effect of color is not allways respected in all teriminals as some color may be simplly
ignored by some teriminals.while the second is a more complex function:
GeoEfficiency.getfloat — Function.UnExported
getfloat(prompt::AbstractString = "?: ", from::Real = -Inf, to::Real = Inf; KW...)::Float64prompts the user with the massage prompt defaults to ?: to input a numerical expression evaluate to a numerical value. check that the numerical value is in interval [from, to[ by default [-∞, ∞[ before returning it as a Float64. throws ArgumentError when the given interval is not valid. if the numerical expression fail to evaluated to numerical value or the numerical value is not in the valid interval the function will warn the user and reprompt him to give a valid expresion.
KW arguments
- value::AbstractString
="nothing": if provided the function will not ask for input from theconsoleand take it as if it where inputted from theconsole[for test propose mainly]. - lower::Bool
=true: whether or not to inculdefromas accepted value. - upper::Bool
=false: whether or not to inculdetoas accepted value.
A blank input (i.e just a return) is considered as being `0.0`.
Input from the `console` can be numerical expression not just a number.
expression like ``5/2`` ; ``5//2`` ; ``pi`` ; ``π/2`` ; ``exp(2)`` ; ``1E-2 `` ; ``5.2/3`` ;
``sin(1)`` ; ``sin(1)^2`` are all valid expressions.Examples
julia> getfloat("input a number:", value="3")
3.0
julia> getfloat("input a number:", value="")
0.0
julia> getfloat("input a number:", value="5/2")
2.5
julia> getfloat("input a number:", value="5//2")
2.5
julia> getfloat("input a number:", value="pi")
3.141592653589793
julia> getfloat("input a number:", value="-2")
-2.0
julia> getfloat("input a number:", value="sin(1)^2")
0.7080734182735712
julia> getfloat("input a number:", 1, 5, value="5", upper=true)
5.0Those function are not exported that is normally the user will not need to use them but they are documented here to allow a developer ranked user to make use of them.
Physics Model
Two abstract detector types defined in the package to classify the detectors, the top most super type,
GeoEfficiency.RadiationDetector — Type.abstract super-supertype of all detectors types
any future detector definition should inherit from RadiationDetector. The second abstract detector Detector is also a sub-type of RadiationDetector but it only accommodates cylindrical type only.
GeoEfficiency.Detector — Type.Detectorabstract supertype of all detectors types of cylidericalish shapes. also can be used to construct any leaf type.
can be used to construct leaf detector.
GeoEfficiency.Detector — Method.Detector()construct and return an object of the Detector leaf types (CylDetector, BoreDetector or WellDetector) according to the input from the console.
all required information is acquired from the console and would warn user on invalid data.
also it can be used to construct a concrete detector depend on the provided arguments.
GeoEfficiency.Detector — Method.Detector(CryRadius::Real, CryLength::Real, HoleRadius::Real, HoleDepth::Real)construct and return well-type, bore-hole or cylindrical detector according to the arguments. it inspect the arguments and call the appropriate leaf type constructor.
if the value(s) of the last argument(s) isre zero, it acts as a missing argument(s).
see also: CylDetector, BoreDetector, WellDetector.
GeoEfficiency.Detector — Method.Detector(CryRadius::Real)same as CylDetector(CryRadius::Real).
GeoEfficiency.Detector — Method.Detector(CryRadius::Real, CryLength::Real)GeoEfficiency.Detector — Method.Detector(CryRadius::Real, CryLength::Real, HoleRadius::Real)same as BoreDetector(CryRadius::Real, CryLength::Real, HoleRadius::Real) except when HoleRadius = 0.0 it acts as CylDetector(CryRadius::Real, CryLength::Real).
Batch Mode Input
GeoEfficiency.detector_info_from_csvFile — Function.UnExported
detector_info_from_csvFile(detectors::AbstractString = Detectors,
datadir::AbstractString = dataDir)return a vector{Detector} based on information in the file of name detectors found in the directory datadir.
- if no path is given the second argument
datadiris default toC:\Users\Mohamed\GeoEfficiencyas set by the constantdataDir. - if no file name is specified the name of the predefined file
Detectors.csvas set by the constantDetectors. - the no argument method is the most useful; other methods are mainly for
test propose.
GeoEfficiency.read_from_csvFile — Function.UnExported
read_from_csvFile(csv_data::AbstractString,
datadir::AbstractString = dataDir)::Vector{Float64}return Vector{Float64} based on data in csv file named csv_data. directory datadir point to where the file is located default to $C:\Users\Mohamed\GeoEfficiency$ as set by the constant dataDir.
GeoEfficiency.read_batch_info — Function.UnExported
read_batch_info()read detectors and sources parameters from the predefined csv files.
Return a tuple (detectorsarray, srcHeightsarray, srcRhosarray, srcRadiiarray, srcLengthsarray, GeoEfficiencyisPoint)
UnExported
read_batch_info(datadir::AbstractString,
detectors::AbstractString,
srcHeights::AbstractString,
srcRhos::AbstractString,
srcRadii::AbstractString,
srcLengths::AbstractString)read detectors and sources parameters from the location given in the argument list.
Return a tuple
(detectors_array,
srcHeights_array,
srcRhos_array,
srcRadii_array,
srcLengths_array,
isPoint)GeoEfficiency.getDetectors — Function.getDetectors(detectors_array::Vector{<:Detector} = Detector[])::Vector{Detector}return the detectors_array as Vector{Detector} extended by the entered detectors and sorted according to the detector volume. prompt the user to input detector parameters from the console.
If no array received in the input an empty array will be created to receive the converted detectors.
getDetectors(detector_info_array::Matrix{<:Real},
detectors_array::Vector{<:Detector} = Detector[];
console_FB=true)::Vector{Detector}return detectors_array as Vector{Detector}, after extending it with the successfully converted detectors. while, attempt to convert detectors from the information in detector_info_array.
if console_FB argument is set to true , the function will call getDetectors() to take input from the console if the detector_info_array is empty or contain no numerical element.
Output Interface
GeoEfficiency.checkResultsDirs — Function.UnExported
checkResultsDirs()make sure that directories for saving the results are already exist or create them if necessary.
GeoEfficiency.writecsv_head — Function.UnExported
writecsv_head(filename::AbstractString, content::VecOrMat{<:Union{Int,Float64}}, head=[])Write content to the comma delimited values file filename. optionally with header head.
GeoEfficiency._max_batch — Constant.Global variable that give a hint to the program on maxumam number of entries per detector displayed on the console in btach mode.
Negative value will display prevent batch results from printed to the `console`.
while `Inf` will print all batch results to the `console`.GeoEfficiency.max_display — Constant.set the default value for the global variable _max_batch
GeoEfficiency._batch — Function.UnExported
_batch(
::Val{true},
detector::Detector,
srcHeights_array::Vector{Float64},
srcRhos_array::Vector{Float64},
srcRadii_array::Vector{Float64},
srcLengths_array::Vector{Float64}
)batch calculation for specialized for point sources. return a tuple of three arrays the detector, the resultsand the path of the CSV file containing results.
The results has columns of headers Height, Rho, GeoEfficiency.
for all arrays srcHeights_array, srcRhos_array, srcRadii_array and srcLengths_array element type should be Float64. if any of them have other numerical element type it should converted to Float64 using float before passing it to this method.
both srcRadii_array, srcLengths_array are completely ignored as this method is for point sources.
UnExported
_batch(
::Val{false},
detector::Detector,
srcHeights_array::Vector{Float64},
srcRhos_array::Vector{Float64},
srcRadii_array::Vector{Float64},
srcLengths_array::Vector{Float64},
)batch calculation for specialized for non-point sources. return a tuple of three arrays the detector, the resultsand the path of the CSV file containing results.
The results has columns of headers AnchorHeight, AnchorRho, srcRadius, srcLength, GeoEfficiency.
for all arrays srcHeights_array, srcRhos_array, srcRadii_array and srcLengths_array element type should be Float64. if any of them have other numerical element type it should converted to Float64 using float before passing it to this method.