Skip to content

Commit

Permalink
GOOD EXPORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Feb 12, 2024
1 parent e8099e9 commit 21fa02e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ ProcessBasedModelling.lhs
## Utility functions

```@docs
default_value
has_variable
new_derived_named_parameter
```
4 changes: 2 additions & 2 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A process subtype `p::Process` extends the following unexported functions:
- `rhs(p)` which is the right-hand-side expression, i.e., the "actual" process.
- (optional) `timescale`, which defaults to [`NoTimeDerivative`](@ref).
- (optional) `lhs(p)` which returns the left-hand-side. Let `τ = timescale(p)`.
Then default `lhs(p)` behavior depends on `τ` as follows:
Then default `lhs(p)` behaviour depends on `τ` as follows:
- Just `lhs_variable(p)` if `τ == NoTimeDerivative()`.
- `Differential(t)(p)` if `τ == nothing`.
- `τ_var*Differential(t)(p)` if `τ isa Union{Real, Num}`. If real,
Expand All @@ -18,7 +18,7 @@ A process subtype `p::Process` extends the following unexported functions:
abstract type Process end

"""
NoTimeDerivative()
ProcessBasedModelling.NoTimeDerivative()
Singleton value that is the default output of the [`timescale`](@ref) function
for variables that do not vary in time autonomously, i.e., they have no d/dt derivative
Expand Down
11 changes: 2 additions & 9 deletions src/ProcessBasedModelling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ include("utils.jl")
include("make.jl")
include("processes_basic.jl")


# TODO: In MAKE, make it so that if a variable does not have a process
# a constant process is created for it if it has a default value.
# Add a keyword `use_default` which would warn if no process but there is default
# and otherwise would error.
# TODO: Make an "addition process" that adds to processes
# It checks whether they target the same variable
# TODO: Package should compose with ODESystem
# so that component-based modelling can be utilized as well.


# TODO: Perhaps not don't export `t, rhs`?
# TODO: Perhaps not don't export `t`?
export t
export Process, ParameterProcess, TimeDerivative, ExpRelaxation
export processes_to_mtkmodel
export new_derived_named_parameter
export hs_variable, default_value

end
9 changes: 6 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export print_system_info, has_variable, default_value
export new_derived_named_parameter, @named_parameters

"""
has_variable(eq, var)
Expand All @@ -13,6 +10,12 @@ function has_variable(eq::Equation, var)
end
has_variable(eqs, var) = any(eq -> has_variable(eq, var), eqs)

"""
default_value(x)
Return the default value of a symbolic variable `x` or `nothing`
if it doesn't have any. Return `x` if `x` is not a symbolic variable.
"""
default_value(x) = x
default_value(x::Num) = default_value(x.val)
function default_value(x::ModelingToolkit.SymbolicUtils.Symbolic)
Expand Down

0 comments on commit 21fa02e

Please sign in to comment.