Skip to content

Commit 79396c0

Browse files
committed
Adapt README and docs
1 parent 2e90ce0 commit 79396c0

File tree

3 files changed

+407
-41
lines changed

3 files changed

+407
-41
lines changed

README.md

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,103 @@
1-
# ModiaLang.jl
1+
# Modia.jl
22

3-
[![The MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/ModiaSim/ModiaLang.jl/blob/master/LICENSE.md)
3+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://modiasim.github.io/Modia.jl/stable)
4+
[![The MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/ModiaSim/Modia.jl/blob/master/LICENSE)
45

5-
ModiaLang is part of [ModiaSim](https://modiasim.github.io/docs/).
6+
The [Modia Tutorial](https://modiasim.github.io/Modia.jl/stable/tutorial/GettingStarted.html) provides an introduction to Modia.
7+
The [Modia3D Tutorial](https://modiasim.github.io/Modia3D.jl/stable/tutorial/GettingStarted.html) provides an introduction to use 3D components in Modia.
8+
Modia is part of [ModiaSim](https://modiasim.github.io/docs/).
69

7-
ModiaLang is usually used via [Modia](https://github.com/ModiaSim/Modia.jl).
8-
9-
ModiaLang provides the core equation-based language of Modia, transformation of a model to ODE form dx/dt = f(x,t) and a thin interface to [DifferentialEquations](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 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).
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
13+
it can be set to `Float32, DoubleFloat, Measurement{Float64}, StaticParticles{Float64,100}`.
1014

1115
## Installation
12-
13-
Typically, a user installs [Modia](https://github.com/ModiaSim/Modia.jl) and does not need
14-
to install ModiaLang separately.
1516

16-
If needed, ModiaLang is installed with (Julia >= 1.5 is required):
17+
The package is registered and is installed with (Julia >= 1.7 is required):
18+
19+
```julia
20+
julia> ]add Modia
21+
```
22+
23+
Furthermore, one or more of the following packages should be installed in order
24+
to be able to generate plots:
25+
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
31+
```
32+
33+
Note, Modia exports all exported symbols of
34+
35+
- [DifferentialEquations](https://github.com/SciML/DifferentialEquations.jl) and of
36+
- [Unitful](https://github.com/PainterQubits/Unitful.jl)
37+
38+
39+
## Examples
40+
41+
The following equations describe a damped pendulum:
42+
43+
![Pendulum-Equations](docs/resources/images/PendulumEquations.png)
44+
45+
46+
where *phi* is the rotation angle, *omega* the angular velocity, *m* the mass, *L* the rod length, *d* a damping constant, *g* the gravity constant and *r* the vector from the origin of the world system to the tip of the pendulum. These equations can be defined, simulated and plotted with
47+
(note, you can define models also without units, or remove units before the model is processed):
1748

1849
```julia
19-
julia> ]add ModiaLang
50+
using Modia
51+
@usingModiaPlot # Use plot package defined with
52+
# ENV["MODIA_PLOT"] or Modia.usePlotPackage(..)
53+
54+
Pendulum = Model(
55+
L = 0.8u"m",
56+
m = 1.0u"kg",
57+
d = 0.5u"N*m*s/rad",
58+
g = 9.81u"m/s^2",
59+
phi = Var(init = 1.57*u"rad"),
60+
w = Var(init = 0u"rad/s"),
61+
equations = :[
62+
w = der(phi)
63+
0.0 = m*L^2*der(w) + d*w + m*g*L*sin(phi)
64+
r = [L*cos(phi), -L*sin(phi)]
65+
]
66+
)
67+
68+
pendulum1 = @instantiateModel(Pendulum)
69+
simulate!(pendulum1, Tsit5(), stopTime = 10.0u"s", log=true)
70+
plot(pendulum1, [("phi", "w"); "r"], figure = 1)
2071
```
2172

73+
The result is the following plot:
74+
75+
![Pendulum-Figure](docs/resources/images/PendulumFigures.png)
76+
77+
Simulation and plotting of the pendulum with normally distributed uncertainty added to some parameters is performed in the following way:
78+
79+
```julia
80+
using Measurements
81+
82+
PendulumWithUncertainties = Pendulum | Map(L = (0.8 ± 0.2)u"m",
83+
m = (1.0 ± 0.2)u"kg",
84+
d = (0.5 ± 0.2)u"N*m*s/rad")
85+
86+
pendulum2 = @instantiateModel(PendulumWithUncertainties,
87+
FloatType = Measurement{Float64})
88+
89+
simulate!(pendulum2, Tsit5(), stopTime = 10.0u"s")
90+
plot(pendulum2, [("phi", "w"); "r"], figure = 2)
91+
```
92+
93+
resulting in the following plot where mean values are shown with thick lines
94+
and standard deviations as area around the mean values.
95+
96+
![PendulumWithUncertainty](docs/resources/images/PendulumWithUncertainties.png)
97+
2298
## Main Developers
2399

24100
- [Hilding Elmqvist](mailto:[email protected]), [Mogram](http://www.mogram.net/).
25-
26101
- [Martin Otter](https://rmc.dlr.de/sr/en/staff/martin.otter/),
27102
[DLR - Institute of System Dynamics and Control](https://www.dlr.de/sr/en).
28103

29-
License: MIT (expat)

docs/src/Functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Functions
22

33
```@meta
4-
CurrentModule = ModiaLang
4+
CurrentModule = Modia
55
```
66

77

@@ -35,7 +35,7 @@ The following functions are provided (for details see
3535
[Functions of ModiaResult](https://modiasim.github.io/ModiaResult.jl/stable/Functions.html#Functions-of-ModiaResult)):
3636

3737
```@meta
38-
CurrentModule = ModiaLang
38+
CurrentModule = Modia
3939
```
4040

4141
| Functions | Description |

0 commit comments

Comments
 (0)