You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ The [Modia Tutorial](https://modiasim.github.io/Modia.jl/stable/tutorial/Getting
7
7
The [Modia3D Tutorial](https://modiasim.github.io/Modia3D.jl/stable/tutorial/GettingStarted.html) provides an introduction to use 3D components in Modia.
8
8
Modia is part of [ModiaSim](https://modiasim.github.io/docs/).
9
9
10
-
[Modia](https://github.com/ModiaSim/Modia.jl) is an environment in form of a Julia package to model and simulate physical systems (electrical, mechanical, thermo-dynamical, etc.) described by differential and algebraic equations. A user defines a model on a high level with model components (like a mechanical body, an electrical resistance, or a pipe) that are physically connected together. A model component is constructed by **`expression = expression` equations** or by Julia structs/functions, such as the pre-defined Modia 3D-mechanical components. The defined model is symbolically processed (for example, equations might be analytically differentiated) with algorithms from package [ModiaBase.jl](https://github.com/ModiaSim/ModiaBase.jl). From the transformed model a Julia function is generated that is used to simulate the model with integrators from [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl).
10
+
[Modia](https://github.com/ModiaSim/Modia.jl) is an environment in form of a Julia package to model and simulate physical systems (electrical, mechanical, thermo-dynamical, etc.) described by differential and algebraic equations. A user defines a model on a high level with model components (like a mechanical body, an electrical resistance, or a pipe) that are physically connected together. A model component is constructed by **`expression = expression` equations** or by Julia structs/functions, such as the pre-defined [Modia3D] (https://github.com/ModiaSim/Modia3D.jl) multibody components. The defined model is symbolically processed (for example, equations might be analytically differentiated) with algorithms from package [ModiaBase.jl](https://github.com/ModiaSim/ModiaBase.jl). From the transformed model a Julia function is generated that is used to simulate the model with integrators from [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl).
11
11
The basic type of the floating point variables is usually `Float64`, but can be set to any
12
-
type `FloatType<:AbstractFloat` via `@instantiateModel(..., FloatType = xxx)`, for example
12
+
type `FloatType <: AbstractFloat` via `@instantiateModel(..., FloatType = xxx)`, for example
13
13
it can be set to `Float32, DoubleFloat, Measurement{Float64}, StaticParticles{Float64,100}`.
14
14
15
15
## Installation
@@ -24,16 +24,22 @@ Furthermore, one or more of the following packages should be installed in order
24
24
to be able to generate plots:
25
25
26
26
```julia
27
-
julia> ]add ModiaPlot_PyPlot # if plotting with PyPlot desired
28
-
add ModiaPlot_GLMakie # if plotting with GLMakie desired
29
-
add ModiaPlot_WGLMakie # if plotting with WGLMakie desired
30
-
add ModiaPlot_CairoMakie # if plotting with CairoMakie desired
27
+
julia> ]add SignalTablesInterface_PyPlot # if plotting with PyPlot desired
28
+
29
+
# currently under registration
30
+
add SignalTablesInterface_GLMakie # if plotting with GLMakie desired
31
+
add SignalTablesInterface_WGLMakie # if plotting with WGLMakie desired
32
+
add SignalTablesInterface_CairoMakie # if plotting with CairoMakie desired
31
33
```
32
34
35
+
or call `t = getValues(instantiatedModel, "time"), y = getValues(instantiatedModel, "y")` to retrieve
36
+
the results in form of vectors and arrays and use any desired plot package for plotting, e.g., `plot(t,y)`.
37
+
33
38
Note, Modia reexports the following definitions
34
39
35
40
-`using Unitful`
36
41
-`using DifferentialEquations`
42
+
-`using SignalTables`
37
43
- and exports functions `CVODE_BDF` and `IDA` of [Sundials.jl](https://github.com/SciML/Sundials.jl).
38
44
39
45
As a result, it is usually sufficient to have `using Modia` in a model to utilize the relevant
|[`printResultInfo`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.printResultInfo)| Print info of the result on stdout. |
76
-
|[`resultInfo`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.resultInfo)| Return info about the result as [DataFrame](https://github.com/JuliaData/DataFrames.jl) table |
77
-
|[`rawSignal`](https://modiasim.github.io/ModiaResult.jl/stable/AbstractInterface.html#ModiaResult.rawSignal)| Return raw signal data given the signal name. |
78
-
|[`getPlotSignal`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.getPlotSignal)| Return signal data prepared for a plot package. |
79
-
|[`signalNames`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.signalNames)| Return all signal names. |
80
-
|[`timeSignalName`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.timeSignalName)| Return the name of the time signal. |
81
-
|[`hasOneTimeSignal`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.hasOneTimeSignal)| Return true if one time signal present. |
82
-
|[`hasSignal`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.hasSignal)| Return true if a signal name is known. |
83
-
|[`getLastValue`](@ref)| Return last available value of variable name |
84
-
|[`defaultHeading`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.defaultHeading`)| Return default heading of a result. |
85
-
86
-
87
-
## Plotting
88
-
89
-
```@meta
90
-
CurrentModule = Modia
91
69
```
70
+
using Modia
92
71
93
-
The simulation result of a model `instantiatedModel` supports the functions of
94
-
[ModiaResult](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html) and
95
-
exports them, so the functions can be accessed without prefixing them with `Modia`.
96
-
97
-
The following functions are provided to **define/inquire the current plot package**:
72
+
FirstOrder = Model(
73
+
T = 0.2u"s",
74
+
x = Var(init=0.3),
75
+
equations = :[u = sin(time/u"s")
76
+
T * der(x) + x = u
77
+
y = 2*x]
78
+
)
79
+
simulate!(firstOrder, stopTime=10)
80
+
showInfo(firstOrder) # list info about the result
81
+
t = getValues(firstOrder, "time")
82
+
y = getValues(firstOrder, "y") # use any plot program: plot(t,y)
|[`@usingModiaPlot`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.@usingModiaPlot)| Expands into `using ModiaPlot_<PlotPackageName>`|
102
-
|[`usePlotPackage`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.usePlotPackage)| Define the plot package to be used. |
103
-
|[`usePreviousPlotPackage`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.usePreviousPlotPackage)| Define the previously defined plot package to be used. |
104
-
|[`currentPlotPackage`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaResult.currentPlotPackage)| Return name defined with `usePlotPackage`|
88
+
See the generated [json-file](../resources/fileio/firstOrder.json).
105
89
106
-
The following functions are available after
90
+
For plotting, a plot package must be installed, e.g.,
107
91
108
-
1.`ENV["MODIA_PLOT"] = XXX` (e.g. in startup.jl file) or
109
-
`usePlotPackage(XXX)` has been executed (XXX = "PyPlot", "GLMakie", "WGLMakie", "CairoMakie", "NoPlot" or "SilentNoPlot") and
110
-
2.`@usingModiaPlot` has been called,
92
+
```julia
93
+
julia> ]add SignalTablesInterface_PyPlot # if plotting with PyPlot desired
94
+
add SignalTablesInterface_GLMakie # if plotting with GLMakie desired
95
+
add SignalTablesInterface_WGLMakie # if plotting with WGLMakie desired
96
+
add SignalTablesInterface_CairoMakie # if plotting with CairoMakie desired
97
+
```
111
98
112
-
to **plot with the currently defined plot package**
113
-
(use `ìnstantiatedModel` as argument `result`, e.g. `plot(instantiatedModel, ...)`):
99
+
In a model, the desired plot package is defined with:
|[`plot`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaPlot_PyPlot.plot)| Plot simulation results in multiple diagrams/figures. |
118
-
|[`saveFigure`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaPlot_PyPlot.saveFigure)| Save figure in different formats on file. |
119
-
|[`closeFigure`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaPlot_PyPlot.closeFigure)| Close one figure |
120
-
|[`closeAllFigures`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaPlot_PyPlot.closeAllFigures)| Close all figures |
121
-
|[`showFigure`](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#ModiaPlot_PyPlot.showFigure)| Show figure in window (only GLMakie, WGLMakie) |
101
+
```julia
102
+
using Modia
103
+
usePlotPackage("PyPlot") # or ENV["SignalTablesPlotPackage"] = "PyPlot"
104
+
```
122
105
123
106
A Modia variable `a.b.c` is identified by a String key `"a.b.c"`.
124
107
The legends/labels of the plots are automatically constructed by the
0 commit comments