diff --git a/Project.toml b/Project.toml index f513255..c96ac7e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ProcessBasedModelling" uuid = "ca969041-2cf3-4b10-bc21-86f4417093eb" authors = ["Datseris "] -version = "1.0.4" +version = "1.0.5" [deps] ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" diff --git a/src/make.jl b/src/make.jl index 77b1424..ad5da09 100644 --- a/src/make.jl +++ b/src/make.jl @@ -26,9 +26,11 @@ or provide a wrapper function for it, and add a default value for `default`. - `name = nameof(type)`: the name of the model - `independent = t`: the independent variable (default: `@variables t`). `t` is also exported by ProcessBasedModelling.jl for convenience. +- `warn_defaut::Bool = true`: if `true`, throw a warning when a variable does not + have an assigned process but it has a default value so that it becomes a parameter instead. """ function processes_to_mtkmodel(_processes, _default = []; - type = ODESystem, name = nameof(type), independent = t + type = ODESystem, name = nameof(type), independent = t, warn_default::Bool = true, ) processes = expand_multi_processes(_processes) default = default_dict(_default) @@ -62,13 +64,15 @@ function processes_to_mtkmodel(_processes, _default = []; else def_val = default_value(added_var) # utilize default value (if possible) if !isnothing(def_val) - @warn(""" - Variable $(added_var) was introduced in process of variable $(introduced[added_var]). - However, a process for $(added_var) was not provided, - and there is no default process for it either. - Since it has a default value, we make it a parameter by adding a process: - `ParameterProcess($(ModelingToolkit.getname(added_var)))`. - """) + if warn_default == true + @warn(""" + Variable $(added_var) was introduced in process of variable $(introduced[added_var]). + However, a process for $(added_var) was not provided, + and there is no default process for it either. + Since it has a default value, we make it a parameter by adding a process: + `ParameterProcess($(ModelingToolkit.getname(added_var)))`. + """) + end parproc = ParameterProcess(added_var) push!(eqs, lhs(parproc) ~ rhs(parproc)) push!(lhs_vars, added_var)