Skip to content

Commit 322831a

Browse files
committed
Used TinyModia 0.8.0 docs and examples -> Modia 0.8.0; adapted by changing TinyModia->Modia and a few minor fixes.
1 parent 87890e7 commit 322831a

36 files changed

+1101
-1937
lines changed

Manifest.toml

Lines changed: 223 additions & 710 deletions
Large diffs are not rendered by default.

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Modia"
22
uuid = "cb905087-75eb-5f27-8515-1ce0ec8e839e"
33
authors = ["Hilding Elmqvist <[email protected]>", "Martin Otter <[email protected]>"]
4-
version = "0.4.1-dev"
4+
version = "0.5.0"
55

66
[deps]
77
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
@@ -11,8 +11,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1111
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
1212

1313
[compat]
14-
DifferentialEquations = "6.16"
15-
ModiaLang = "0.7.2"
14+
DifferentialEquations = "6.17, 6.16"
15+
ModiaLang = "0.8.0"
1616
Reexport = "1.0, 0.2"
1717
Unitful = "1.6, 1.5, 1.4, 1.3"
18-
julia = "1.6, 1.5"
18+
julia = "1.7, 1.6, 1.5"

docs/make.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Documenter, Modia, ModiaLang, ModiaPlot
1+
using Documenter, Modia, ModiaLang, ModiaResult, ModiaPlot_PyPlot
22

33
makedocs(
44
#modules = [Modia],
@@ -7,14 +7,15 @@ makedocs(
77
format = Documenter.HTML(prettyurls = false),
88
pages = [
99
"Home" => "index.md",
10-
"Modia Tutorial" => Any[
11-
"tutorial/GettingStarted.md",
12-
"tutorial/Modeling.md",
13-
"tutorial/Simulation.md",
14-
"tutorial/FloatingPointTypes.md",
15-
"tutorial/Appendix.md"
16-
],
10+
"Tutorial" => [
11+
"tutorial/Tutorial.md"
12+
"tutorial/GettingStarted.md"
13+
"tutorial/Modeling.md"
14+
"tutorial/Simulation.md"
15+
"tutorial/FloatingPointTypes.md"
16+
"tutorial/Appendix.md"
17+
],
1718
"Functions" => "Functions.md",
1819
"Internal" => "Internal.md"
19-
]
20+
]
2021
)
-19.8 KB
Binary file not shown.
26.3 KB
Loading
27.7 KB
Loading

docs/src/Functions.md

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
CurrentModule = ModiaLang
55
```
66

7+
78
## Instantiation
89

910
```@docs
@@ -17,17 +18,66 @@ instantiateModel
1718
simulate!
1819
```
1920

20-
## Plotting
2121

22-
The results of a simulation of a model `instantiatedModel` can be visualized with
23-
function [ModiaPlot.plot](https://modiasim.github.io/ModiaPlot.jl/stable/Functions.html#ModiaPlot.plot)
24-
that produces line plots of the result time series.
25-
A variable `a.b.c` is identified by a String key `"a.b.c"`.
22+
## Linearization
23+
24+
```@docs
25+
linearize!
26+
```
27+
28+
29+
## Results and Plotting
30+
31+
The simulation result of a model `instantiatedModel` supports the abstract interface
32+
[ModiaResult](https://modiasim.github.io/ModiaResult.jl/stable/index.html) and
33+
exports them, so the functions can be accessed without prefixing them with `Modia`.
34+
The following functions are provided (for details see
35+
[Functions of ModiaResult](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#Functions-of-ModiaResult)):
36+
37+
```@meta
38+
CurrentModule = ModiaLang
39+
```
40+
41+
| Functions | Description |
42+
|:---------------------------------|:--------------------------------------------------|
43+
| `@usingModiaPlot` | Expands into `using ModiaPlot_<PlotPackageName>` |
44+
| `usePlotPackage` | Define the plot package to be used. |
45+
| `usePreviousPlotPackage` | Define the previously defined plot package to be used. |
46+
| `currentPlotPackage` | Return name defined with `usePlotPackage` |
47+
| `resultInfo` | Return info about the result as [DataFrame](https://github.com/JuliaData/DataFrames.jl) table |
48+
| `printResultInfo` | Print info of the result on stdout. |
49+
| `rawSignal` | Return raw signal data given the signal name. |
50+
| `getPlotSignal` | Return signal data prepared for a plot package. |
51+
| `defaultHeading` | Return default heading of a result. |
52+
| `signalNames` | Return all signal names. |
53+
| `timeSignalName` | Return the name of the time signal. |
54+
| `hasOneTimeSignal` | Return true if one time signal present. |
55+
| `hasSignal` | Return true if a signal name is known. |
56+
57+
58+
The following functions are available after `ENV["MODIA_PLOT"] = XXX` or
59+
`@usingModiaPlot(XXX)` have been executed
60+
(for details see
61+
[Functions of Plot Package](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#Functions-of-Plot-Package)):
62+
63+
64+
| Functions | Description |
65+
|:-------------------|:----------------------------------------------------------|
66+
| `plot` | Plot simulation results in multiple diagrams/figures. |
67+
| `saveFigure` | Save figure in different formats on file. |
68+
| `closeFigure` | Close one figure |
69+
| `closeAllFigures` | Close all figures |
70+
| `showFigure` | Show figure in window (only GLMakie, WGLMakie) |
71+
72+
73+
A Modia variable `a.b.c` is identified by a String key `"a.b.c"`.
2674
The legends/labels of the plots are automatically constructed by the
2775
names and units of the variables. Example:
2876

2977
```julia
30-
using ModiaPlot
78+
using Modia
79+
@usingModiaPlot
80+
3181
instantiatedModel = @instantiatedModel(...)
3282
simulate!(instantiatedModel, ...)
3383
plot(instantiatedModel,
@@ -40,25 +90,16 @@ generates the following plot:
4090

4191
![Matrix-of-Plots](../resources/images/matrix-of-plots.png)
4292

43-
The underlying line plot is generated by [GLMakie](https://github.com/JuliaPlots/GLMakie.jl).
44-
45-
46-
## Inquiries
47-
48-
```@meta
49-
CurrentModule = ModiaLang
50-
```
5193

52-
```@docs
53-
get_result
54-
get_lastValue
55-
```
94+
## PathPlanning
5695

57-
```@meta
58-
CurrentModule = ModiaPlot
59-
```
96+
There are some pre-defined functions to define reference paths
6097

6198
```@docs
62-
hasSignal
63-
getNames
64-
```
99+
PTP_path
100+
pathEndTime
101+
getPosition!
102+
getPosition
103+
getIndex
104+
getPath
105+
```

docs/src/Internal.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ addToResult!
2121
getFloatType
2222
baseType
2323
measurementToString
24-
```
24+
```
25+
26+
## Inquiries in Model
27+
28+
```@docs
29+
isInitial
30+
isTerminal
31+
isEvent
32+
isFirstEventIteration
33+
isFirstEventIterationDirectlyAfterInitial
34+
isAfterSimulationStart
35+
isZeroCrossing
36+
storeResults
37+
```

docs/src/index.md

Lines changed: 92 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,113 @@
11
# Modia Documentation
22

3-
[Modia](https://github.com/ModiaSim/Modia.jl) is a Julia package for modeling and simulation of multidomain engineering systems described by differential equations, algebraic equations, and (space-discretized) partial differential equations. It shares many powerful features of the [Modelica language](https://www.modelica.org/modelicalanguage), together with features not available in Modelica.
3+
[Modia](https://github.com/ModiaSim/Modia.jl) is a minimalistic 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. 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).
4+
The basic type of the floating point variables is usually `Float64`, but can be set to any
5+
type `FloatType<:AbstractFloat` via `@instantiateModel(..., FloatType = xxx)`, for example
6+
it can be set to `Float32, DoubleFloat, Measurement{Float64}, StaticParticles{Float64,100}`.
47

5-
A user defines a model on a high level with model components (like an electrical resistance, a rotational inertia, a rod with heat transfer, a PI controller etc.) that are physically connected together. A model component is constructed by "expression = expression" equations. The defined model is symbolically transformed to ODE form dx/dt = f(x,t). For example, equations might be analytically differentiated, ODE states selected, linear equation systems numerically solved when evaluating the transformed model. From the transformed model a Julia function is generated that is used to simulate the model with integrators from [DifferentialEquations](https://github.com/SciML/DifferentialEquations.jl). Simulation results can be plotted with [ModiaPlot](https://github.com/ModiaSim/ModiaPlot.jl), that provides a convenient interface to [GLMakie](https://github.com/JuliaPlots/GLMakie.jl) line plots.
6-
7-
Other packages from the Julia eco-systems that are specially supported:
8-
9-
- [Unitful](https://github.com/PainterQubits/Unitful.jl) to define and process physical units.
10-
- [Measurements](https://github.com/JuliaPhysics/Measurements.jl) to perform simulations with uncertain parameters and initial values with linear propagation theory.
11-
- [MonteCarloMeasurements](https://github.com/baggepinnen/MonteCarloMeasurements.jl) to perform simulations with uncertain parameters and initial values with particle theory.
8+
## Installation
129

10+
The package is registered and is installed with (Julia >= 1.5 is required):
1311

14-
## Installation
12+
```julia
13+
julia> ]add Modia
14+
```
1515

16-
Modia and ModiaPlot are registered and are installed with (Julia >= 1.5 is required):
16+
Furthermore, one or more of the following packages should be installed in order
17+
to be able to generate plots:
1718

1819
```julia
19-
julia> ]add Modia, ModiaPlot
20+
julia> ]add ModiaPlot_PyPlot # if plotting with PyPlot desired
21+
add ModiaPlot_GLMakie # if plotting with GLMakie desired
22+
add ModiaPlot_WGLMakie # if plotting with WGLMakie desired
23+
add ModiaPlot_CairoMakie # if plotting with CairoMakie desired
2024
```
2125

2226
It is recommended to also add the following packages, in order that all tests and examples can be executed in your standard environment:
2327

2428
```julia
25-
julia> ]add Measurements
26-
add MonteCarloMeasurements
27-
add Distributions
28-
add Interpolations
29+
julia> ]add Unitful, DifferentialEquations, Measurements
30+
add MonteCarloMeasurements, Distributions
2931
```
3032

3133
## Release Notes
3234

33-
### Version 0.4.0
3435

35-
- Initial version of new Modia design.
36+
### Version 0.8.0
37+
38+
- Improved scalability by using OrderedDicts instead of named tuples for models, variables and parameter modifications.
39+
- Speed improvements for structural and symbolic algorithms.
40+
- Added support for state events, time events and synchronous operators.
41+
- Added support for mixed linear equation systems having Real and Boolean unknowns.
42+
- Added support for user-defined components defined by structs and functions
43+
(multibody modeling with Modia3D is based on this feature).
44+
This makes it possible to utilize algorithms specialized for a component.
45+
- Added support for numerical and analytic linearization.
46+
- Added support for propagation of parameters (e.g. deep in a model, the value of a parameter can be defined as a function of some top level parameter and this parameter is changed before simulation starts).
47+
- New small model libraries Translational.jl and PathPlanning.jl added.
48+
- Result storage changed: `sol = simulate!(...)` calls internally `sol = solve(..)` from DifferentialEquations.jl. `sol` contains time and the states at the communication time grid and
49+
at events. This is now kept in simulate(..), so the return value of simulate!(..) can be exactly used as if `solve(..)` would have been used directly.
50+
- The plot(..) command now supports the following underlying plot packages:
51+
[PyPlot](https://github.com/JuliaPy/PyPlot.jl),
52+
[GLMakie](https://github.com/JuliaPlots/GLMakie.jl),
53+
[WGLMakie](https://github.com/JuliaPlots/WGLMakie.jl), and
54+
[CairoMakie](https://github.com/JuliaPlots/CairoMakie.jl).
55+
It is also possible to select `NoPlot`, to ignore `plot(..)` calls
56+
or `SilenNoPlot` to ignore `plot(..)` calls silently. The latter is useful for `runtests.jl`.
57+
Note, often [PyPlot](https://github.com/JuliaPy/PyPlot.jl) is the best choice.
58+
59+
Changes that are **not backwards compatible** to version 0.7.x:
60+
61+
- Models are OrderedDicts and no longer NamedTuples.
62+
63+
- simulate!(..):
64+
- If FloatType=Float64 and no algorithm is defined, then Sundials.CVODE\_BDF() is used
65+
instead of the default algorithm of DifferentialEquations as in 0.7. The reason is that Modia models
66+
are usually large and expensive to evaluate and have often stiff parts, so that multi-step
67+
methods are often by far the best choice. CVODE_BDF() seems to be a good choice in many applications
68+
(another algorithm should be used, if there are many events, highly oscillatory vibrations, or if all states are non-stiff).
69+
- The default value of `stopTime` is equal to `startTime` (which has a default value of 0.0 s), and is no longer 1.0 s.
70+
71+
- Plotting is defined slightly differently (`@useModiaPlot`, instead of `using ModiaPlot`).
72+
73+
74+
### Version 0.7.3
75+
76+
- Evaluation and propagation of parameter expressions (also in simulate!(..., merge=Map(...))).
77+
Propagation of start/init values of states is not yet supported.
78+
79+
- State events supported.
80+
81+
82+
### Version 0.7.2
83+
84+
- Missing dependency of Test package added.
85+
86+
### Version 0.7.1
87+
88+
- Variable constructor `Var(...)` introduced. For example:
89+
`v = input | Var(init = 1.2u"m")`.
90+
For details see section [A.1 Var constructor](@ref).
91+
92+
- Functions are called in the scope where macro [`@instantiateModel`](@ref) is called.
93+
94+
- New arguments of function [`simulate!`](@ref):
95+
- Parameter and init/start values can be changed with argument `merge`.
96+
- A simulation can be checked with argument `requiredFinalStates`.
97+
- Argument `logParameters` lists the parameter and init/start values used for the simulation.
98+
- Argument `logStates` lists the states, init, and nominal values used for the simulation.
99+
100+
- `end` in array ranges is supported, for example `v[2:end]`.
101+
102+
- New (small) model library `Modia/models/HeatTransfer.jl`.
103+
104+
- Modia Tutorial improved.
105+
106+
- [Functions](@ref) docu improved.
107+
108+
### Version 0.7.0
109+
110+
- Initial version, based on code developed for Modia 0.6 and ModiaMath 0.6.
36111

37112

38113
## Main developers

0 commit comments

Comments
 (0)