@@ -59,51 +59,13 @@ plot(sol)
59
59
As you can see, generating an ODESystem is as simple as creating an array of equations
60
60
and passing it to the ` ODESystem ` constructor.
61
61
62
- ## Understanding the Difference Between the Julia Variable and the Symbolic Variable
63
-
64
- In the most basic usage of ModelingToolkit and Symbolics, the name of the Julia variable
65
- and the symbolic variable are the same. For example, when we do:
66
-
67
- ``` @example scripting
68
- @variables a
69
- ```
70
-
71
- the name of the symbolic variable is ` a ` and same with the Julia variable. However, we can
72
- de-couple these by setting ` a ` to a new symbolic variable, for example:
73
-
74
- ``` @example scripting
75
- b = only(@variables(a))
76
- ```
77
-
78
- Now the Julia variable ` b ` refers to the variable named ` a ` . However, the downside of this current
79
- approach is that it requires that the user writing the script knows the name ` a ` that they want to
80
- place to the variable. But what if for example we needed to get the variable's name from a file?
81
-
82
- To do this, one can interpolate a symbol into the ` @variables ` macro using ` $ ` . For example:
83
-
84
- ``` @example scripting
85
- a = :c
86
- b = only(@variables($a))
87
- ```
88
-
89
- In this example, ` @variables($a) ` created a variable named ` c ` , and set this variable to ` b ` .
90
-
91
- Variables are not the only thing with names. For example, when you build a system, it knows its name
92
- that name is used in the namespacing. In the standard usage, again the Julia variable and the
93
- symbolic name are made the same via:
94
-
95
- ``` @example scripting
96
- @named fol_model = ODESystem(eqs, t)
97
- ```
98
-
99
- However, one can decouple these two properties by noting that ` @named ` is simply shorthand for the
100
- following:
62
+ ` @named ` automatically gives a name to the ` ODESystem ` , and is shorthand for
101
63
102
64
``` @example scripting
103
- fol_model = ODESystem(eqs, t; name = :fol_model)
65
+ fol_model = ODESystem(eqs, t; name = :fol_model) # @named fol_model = ODESystem(eqs, t)
104
66
```
105
67
106
- Thus if we had read a name from a file and wish to populate an ` ODESystem ` with said name, we could do:
68
+ Thus, if we had read a name from a file and wish to populate an ` ODESystem ` with said name, we could do:
107
69
108
70
``` @example scripting
109
71
namesym = :name_from_file
0 commit comments