Skip to content
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 new get_params - function where user can pass dict of parameters #38

Merged
merged 1 commit into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/TDAC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,20 @@ function tdac(params::tdac_params)
return state_true, state_avg
end

# Initialise params struct with user-defined dict of values.
function get_params(user_input_dict::Dict)

user_input = (; (Symbol(k) => v for (k,v) in user_input_dict)...)
params = tdac_params(;user_input...)

end

function get_params(path_to_input_file::String)

# Read input provided in a yaml file. Overwrite default input parameters with the values provided.
if isfile(path_to_input_file)
user_input_dict = YAML.load_file(path_to_input_file)
user_input = (; (Symbol(k) => v for (k,v) in user_input_dict)...)
params = tdac_params(;user_input...)
params = get_params(user_input_dict)
if params.verbose
println("Read input parameters from ",path_to_input_file)
end
Expand Down