|
1 | 1 | """ |
2 | 2 | $(TYPEDSIGNATURES) |
3 | 3 |
|
4 | | -Get the set of independent variables for the given system. |
| 4 | +Get an iterable over the independent variables for the given system. Default to an empty |
| 5 | +vector. |
5 | 6 | """ |
6 | 7 | function independent_variables end |
| 8 | +independent_variables(::Any) = [] |
7 | 9 |
|
8 | 10 | """ |
9 | 11 | $(TYPEDSIGNATURES) |
10 | 12 |
|
11 | | -Check if the given sym is an independent variable in the given system. Defaults |
12 | | -to `false` if not implemented for the given system/container type. |
| 13 | +Check if the given sym is an independent variable in the given system. Default to checking |
| 14 | +if the given `sym` exists in the iterable returned by `independent_variables`. |
13 | 15 | """ |
14 | 16 | function is_indep_sym end |
15 | 17 |
|
| 18 | +function is_indep_sym(store, sym) |
| 19 | + any(isequal(Symbol(sym)), Symbol.(independent_variables(store))) |
| 20 | +end |
| 21 | + |
16 | 22 | """ |
17 | 23 | $(TYPEDSIGNATURES) |
18 | 24 |
|
19 | | -Get the set of states for the given system. |
| 25 | +Get an iterable over the states for the given system. Default to an empty vector. |
20 | 26 | """ |
21 | 27 | function states end |
22 | 28 |
|
| 29 | +states(::Any) = [] |
| 30 | + |
23 | 31 | """ |
24 | 32 | $(TYPEDSIGNATURES) |
25 | 33 |
|
26 | | -Find the index of the given sym in the given system. |
| 34 | +Find the index of the given sym in the given system. Default to the index of the first |
| 35 | +symbol in the iterable returned by `states` which matches the given `sym`. Return |
| 36 | +`nothing` if the given `sym` does not match. |
27 | 37 | """ |
28 | 38 | function state_sym_to_index end |
29 | 39 |
|
| 40 | +function state_sym_to_index(store, sym) |
| 41 | + findfirst(isequal(Symbol(sym)), Symbol.(states(store))) |
| 42 | +end |
| 43 | + |
30 | 44 | """ |
31 | 45 | $(TYPEDSIGNATURES) |
32 | 46 |
|
33 | | -Check if the given sym is a state variable in the given system. Defaults |
34 | | -to `false` if not implemented for the given system/container type. |
| 47 | +Check if the given sym is a state variable in the given system. Default to checking if |
| 48 | +the value returned by `state_sym_to_index` is not `nothing`. |
35 | 49 | """ |
36 | 50 | function is_state_sym end |
37 | 51 |
|
| 52 | +is_state_sym(store, sym) = !isnothing(state_sym_to_index(store, sym)) |
| 53 | + |
38 | 54 | """ |
39 | 55 | $(TYPEDSIGNATURES) |
40 | 56 |
|
41 | | -Get the set of parameters variables for the given system. |
| 57 | +Get an iterable over the parameters variables for the given system. Default to an empty |
| 58 | +vector. |
42 | 59 | """ |
43 | 60 | function parameters end |
44 | 61 |
|
| 62 | +parameters(::Any) = [] |
| 63 | + |
45 | 64 | """ |
46 | 65 | $(TYPEDSIGNATURES) |
47 | 66 |
|
48 | | -Find the index of the given sym in the given system. |
| 67 | +Find the index of the given sym in the given system. Default to the index of the first |
| 68 | +symbol in the iterable retruned by `parameters` which matches the given `sym`. Return |
| 69 | +`nothing` if the given `sym` does not match. |
49 | 70 | """ |
50 | 71 | function param_sym_to_index end |
51 | 72 |
|
| 73 | +param_sym_to_index(store, sym) = findfirst(isequal(Symbol(sym)), Symbol.(parameters(store))) |
| 74 | + |
52 | 75 | """ |
53 | 76 | $(TYPEDSIGNATURES) |
54 | 77 |
|
55 | | -Check if the given sym is a parameter variable in the given system. Defaults |
56 | | -to `false` if not implemented for the given system/container type. |
| 78 | +Check if the given sym is a parameter variable in the given system. Default |
| 79 | +to checking if the value returned by `param_sym_to_index` is not `nothing`. |
57 | 80 | """ |
58 | 81 | function is_param_sym end |
| 82 | + |
| 83 | +is_param_sym(store, sym) = !isnothing(param_sym_to_index(store, sym)) |
0 commit comments