Skip to content

Commit

Permalink
make literal parameter allowable in LHS timescale
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Apr 11, 2024
1 parent b918f48 commit 3ed7782
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProcessBasedModelling"
uuid = "ca969041-2cf3-4b10-bc21-86f4417093eb"
authors = ["Datseris <datseris.george@gmail.com>"]
version = "1.2.0"
version = "1.2.1"

[deps]
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Expand Down
5 changes: 4 additions & 1 deletion src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The type must extend the following functions from the module `ProcessBasedModell
- (optional) `lhs(p)` which returns the left-hand-side. Let `τ = timescale(p)`.
Then default `lhs(p)` behaviour depends on `τ` as follows:
- Just `lhs_variable(p)` if `τ == NoTimeDerivative()`.
- `Differential(t)(p)` if `τ == nothing`.
- `Differential(t)(p)` if `τ == nothing`, or multiplied with a number
if `τ isa LiteralParameter`.
- `τ_var*Differential(t)(p)` if `τ isa Union{Real, Num}`. If real,
a new named parameter `τ_var` is created that has the prefix `:τ_` and then the
lhs-variable name and has default value `τ`. Else if `Num`, `τ_var = τ` as given.
Expand Down Expand Up @@ -64,6 +65,8 @@ function lhs(p::Process)
return D(v) # `D` is the MTK canonical variable for time derivative
elseif τ isa NoTimeDerivative || iszero(τ) # no time variability
return v
elseif τ isa LiteralParameter
return τ.p*D(v)
else # τ is either Num or Real
τvar = new_derived_named_parameter(v, τ, "τ")
return τvar*D(v)
Expand Down

0 comments on commit 3ed7782

Please sign in to comment.