-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add constructor for ADLChargeDriftModel
#369
Conversation
const defaultADLfile = joinpath(get_path_to_example_config_files(), "ADLChargeDriftModel/drift_velocity_config.yaml") | ||
function ADLChargeDriftModel(configfilename::AbstractString = defaultADLfile; kwargs...) | ||
ADLChargeDriftModel(parse_config_file(configfilename); kwargs...) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no config file is provided, the default ADLChargeDriftModel parameters are loaded as basis.
@inline _parse_value(::Type{T}, x::Quantity, unit::Unitful.Units) where {T} = begin | ||
if dimension(x) != dimension(unit) throw(ConfigFileError("The quantity '$(x)' cannot be converted to unit '$(unit)'")) end | ||
T(to_internal_units(float(x))) | ||
end | ||
@inline _parse_value(::Type{T}, s::String, unit::Unitful.Units) where {T} = _parse_value(T, uparse(s), unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_parse_value
now also checks whether the passed value has the correct dimensions and throws a ConfigFileError
if it doesn't
@testset "Modify mobility parameters using keyword arguments" begin | ||
cdm = ADLChargeDriftModel{Float64}(e100μ0 = 40000u"cm^2/(V*s)", e111μn = 5u"cm^2/(V*s)", h100β = 2, h111E0 = 50u"V/cm") | ||
@test cdm.electrons.axis100.mu0 == 4.0 # internal unit is m^2/(V*s) | ||
@test cdm.electrons.axis111.mun == 0.0005 # internal unit is m^2/(V*s) | ||
@test cdm.holes.axis100.beta == 2.0 # no unit conversion | ||
@test cdm.holes.axis111.E0 == 5000.0 # internal unit is V/m | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally, the parameter values are stored in internal_units
This PR improves the convenience of the
ADLChargeDriftModel
constructor and closes #252.Previously, the
ADLChargeDriftModel
was always constructed from a config file. Now: