Skip to content

Commit 0dda4f1

Browse files
Merge pull request #134 from alhirzel/doc-typos-and-formatting
fix some documentation typos / formatting to one sentence per line
2 parents 421d7e0 + 7bdf1e9 commit 0dda4f1

File tree

4 files changed

+66
-57
lines changed

4 files changed

+66
-57
lines changed

docs/src/tutorial/Appendix.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ OrderedDict{Symbol, Any} with 2 entries:
7878
:r => 200
7979
```
8080

81-
The values can also be a quoted expression, i.e. an expression enclosed in `:( )`, an array of quoted expressions encloded in `:[ ]` or just a quoted symbol, `:x`. This mechanism is used to encode equations and expressions of the model which needs to be manipulated before the model can be simulated.
81+
The values can also be a quoted expression, i.e. an expression enclosed in `:( )`, an array of quoted expressions enclosed in `:[ ]` or just a quoted symbol, `:x`.
82+
This mechanism is used to encode equations and expressions of the model which needs to be manipulated before the model can be simulated.
8283

8384
Julia defines a very useful merge operation between dictionaries:
8485

@@ -90,7 +91,8 @@ OrderedDict{Symbol, Any} with 3 entries:
9091
:r => 200
9192
```
9293

93-
If a key already exists `q` in the first dictionary, it's value is overwritten otherwise it's added, `r`. Such a merge semantics allows for unification of parameter modifications and inheritance as will be demonstrated below.
94+
If a key already exists in the first dictionary (like `:q`), its value is overwritten (like `:r`) otherwise it's added (like `:p`).
95+
Such a merge semantic allows for unification of parameter modifications and inheritance as will be demonstrated below.
9496

9597
## A.3 MergeModels algorithm
9698

docs/src/tutorial/GettingStarted.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 1 Getting Started
2-
2+
33
A simple differential equation with $x(t) \in \R$
44

55
```math
@@ -36,18 +36,18 @@ plot(simpleModel, ("x", "der(x)"))
3636
```
3737

3838
A model is defined with a constructor `Model` taking a comma separated list of name/value pairs.
39-
The model consist of a definition of a parameter `T` with default value 0.2.
39+
The model consists of a definition of a parameter `T` with default value 0.2.
4040
Constructor `Var` with an `init` key is used to define the initial condition `0.2` of the state `x`, and one equation. Equations can have a Julia expression on both sides of the equal sign and are given as a *quoted* array expression `:[ ]` assigned to a unique identifier such as `equation`.
4141

42-
Macro `@instantiateModel(..)` symbolically processes the model, in particular solves the equation
42+
The macro `@instantiateModel(..)` symbolically processes the model, in particular solves the equation
4343
for the derivative `der(x)`, so the following equation will be used by the integrator:
4444

4545
```math
4646
\frac{dx}{dt} = (1 - x) / T
4747
```
4848

4949
Furthermore, a Julia function is generated and compiled to evaluate this equation. `@instantiateModel(..)`
50-
returns an instance containing all the information needed for the further steps.
50+
returns an instance containing all the information needed for the next steps.
5151

5252
The first [`simulate!`](@ref) function performs one simulation with the Modia default integrator
5353
`Sundials.CVODE_BDF()`. The second `simulate!` call defines the integrator as second argument.

docs/src/tutorial/Modeling.md

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ equations = :[
152152

153153
## 2.4 Hierarchical modeling
154154

155-
Sofar, the composition of models have resulted in dictionaries of key/value pairs with values being numeric values or quoted expressions. Hierarchical models are obtained if the values themself are `Models`, i.e. dictionaries. A model with two filters can, for example, be defined as follows:
155+
So far, the composition of models has resulted in dictionaries of key/value pairs with values being numeric values or quoted expressions.
156+
Hierarchical models are obtained if the values themselves are `Models`, i.e. dictionaries.
157+
A model with two filters can, for example, be defined as follows:
156158

157159
```julia
158160
TwoFilters = (
@@ -161,7 +163,7 @@ TwoFilters = (
161163
)
162164
```
163165

164-
Note, that the previous definitions of HighPassFilter and LowPassFilter was used instead of making the Model defintions inline.
166+
Note, that the previous definitions of `HighPassFilter` and `LowPassFilter` was used instead of making the Model definitions inline.
165167

166168
A band pass filter is a series connection of a high pass filter and a low pass filter and can be described as:
167169

@@ -178,9 +180,11 @@ BandPassFilter = (
178180
)
179181
```
180182

181-
A new input, `u`, has been defined which is propagated to `high.u`. The series connection itself is obtained by the equation `low.u = high.y`. Note, that dot-notation is allowed in equations.
183+
A new input, `u`, has been defined which is propagated to `high.u`.
184+
The series connection itself is obtained by the equation `low.u = high.y`.
185+
Note, that dot-notation is allowed in equations.
182186

183-
The input and output for the BandPassFilter when using the same input definition as for the TestLowPassFilter
187+
The input and output for the `BandPassFilter` when using the same input definition as for the `TestLowPassFilter`
184188

185189
```julia
186190
TestBandPassFilter = BandPassFilter | Map(
@@ -199,22 +203,29 @@ is shown below:
199203

200204
## 2.5 Physically oriented modeling
201205

202-
Sofar, only signal flow modeling has been used, i.e. input/output blocks coupled with equations between outputs and inputs. For object oriented modeling more high level constructs are neccessary. Coupling is then acausal and involves potentials such as electric potential, positions, pressure, etc. and flows such as electric current, forces and torques and mass flow rate.
206+
So far, only signal flow modeling has been used, i.e. input/output blocks coupled with equations between outputs and inputs.
207+
For object oriented modeling more high level constructs are necessary.
208+
Coupling is then acausal and involves potentials such as electric potential, positions, pressure, etc. and flows such as electric current, forces and torques and mass flow rate.
203209

204210
### 2.5.1 Connectors
205211

206-
Models which contain any `flow` variable, i.e. a variable having an attribute `flow=true`, are considered connectors. Connectors must have equal number of flow and potential variables, i.e. variables having an attribute `potential=true`, and have matching array sizes. Connectors may not have any equations. An example of an electrical connector with potential (in Volt) and current (in Ampere) is shown below.
212+
Models which contain any `flow` variable, i.e. a variable having an attribute `flow=true`, are considered connectors.
213+
Connectors must have equal number of flow and potential variables, i.e. variables having an attribute `potential=true`, and have matching array sizes.
214+
Connectors may not have any equations.
215+
An example of an electrical connector with potential (in Volt) and current (in Ampere) is shown below.
207216

208217
```julia
209218
Pin = Model( v = potential, i = flow )
210219
```
211-
`potential` is a shortcut for `Var(potential=true)` and similarly for `flow`.
220+
221+
The value `potential` is a shortcut for `Var(potential=true)` and similarly for `flow`.
212222

213223
### 2.5.2 Components
214224

215-
Components are declared in a similar ways as blocks. However, the interfaces between components are defined using connector instances.
225+
Components are declared in a similar ways as blocks.
226+
However, the interfaces between components are defined using connector instances.
216227

217-
An electrical resistor can be descibed as follows:
228+
An electrical resistor can be described as follows:
218229

219230
```julia
220231
Resistor = Model(
@@ -231,9 +242,12 @@ Resistor = Model(
231242

232243
### 2.5.3 Inheritance
233244

234-
Various physical components sometimes share common properties. One mechanism to handle this is to use inheritance. In Modia, **merging** is used.
245+
Various physical components sometimes share common properties.
246+
One mechanism to handle this is to use inheritance.
247+
In Modia, **merging** is used.
235248

236-
Electrical components such as resistors, capacitors and inductors are categorized as oneports which have two pins. Common properties are: constraint on currents at the pins and definitions of voltage over the component and current through the component.
249+
Electrical components such as resistors, capacitors and inductors are categorized as oneports which have two pins.
250+
Common properties are: constraint on currents at the pins and definitions of voltage over the component and current through the component.
237251

238252
```julia
239253
OnePort = Model(
@@ -245,7 +259,7 @@ OnePort = Model(
245259
i = p.i ] )
246260
```
247261

248-
Having such a OnePort definition makes it convenient to define electrical component models by merging OnePort with specific parameter definitions with default values and equations:
262+
Having such a `OnePort` definition makes it convenient to define electrical component models by merging `OnePort` with specific parameter definitions with default values and equations:
249263

250264
```julia
251265
Resistor = OnePort | Model( R = 1.0u"Ω", equation = :[ R*i = v ], )
@@ -256,25 +270,18 @@ Inductor = OnePort | Model( L = 1.0u"H", i=Map(init=0.0u"A"), equation = :[ L*de
256270

257271
ConstantVoltage = OnePort | Model( V = 1.0u"V", equation = :[ v = V ] )
258272
```
273+
259274
The merged `Resistor` is shown below:
260275

261276
```julia
262277
Resistor = Model(
263278
p = Model(
264-
v = Var(
265-
potential = true,
266-
),
267-
i = Var(
268-
flow = true,
269-
),
279+
v = Var(potential = true),
280+
i = Var(flow = true),
270281
),
271282
n = Model(
272-
v = Var(
273-
potential = true,
274-
),
275-
i = Var(
276-
flow = true,
277-
),
283+
v = Var(potential = true),
284+
i = Var(flow = true),
278285
),
279286
equations = :([v = p.v - n.v; 0 = p.i + n.i; i = p.i, R * i = v]),
280287
R = 1.0 Ω,
@@ -284,9 +291,11 @@ Resistor = Model(
284291
### 2.5.4 Connections
285292

286293
Connections are described as an array of tuples listing the connectors that are connected:
294+
287295
```julia
288296
( <connect reference 1>, <connect reference 2>, ... )
289297
```
298+
290299
A connect reference has either the form 'connect instance name' or 'component instance name'.'connect instance name' with 'connect instance name' being either a connector instance, input or output variable.
291300

292301
Examples
@@ -299,7 +308,8 @@ Examples
299308
]
300309
```
301310

302-
For connectors, all the potentials of the connectors in the same connect tuple are set equal and the sum of all incoming flows to the model are set equal to the sum of the flows into sub-components. A Modelica inspired form of connections, i.e. connect-equations, are also supported:
311+
For connectors, all the potentials of the connectors in the same connect tuple are set equal and the sum of all incoming flows to the model are set equal to the sum of the flows into sub-components.
312+
A Modelica inspired form of connections, i.e. connect-equations, are also supported:
303313

304314
```julia
305315
equations = :[
@@ -316,8 +326,7 @@ Having the above electrical component models, enables defining a filter
316326

317327
![Filter Circuit](../../resources/images/Filter.png)
318328

319-
by instanciating components, setting parameters and defining connections.
320-
329+
by instantiating components, setting parameters and defining connections.
321330

322331
```julia
323332
Filter = (
@@ -345,7 +354,10 @@ The connect tuples are translated to:
345354

346355
### 2.5.6 Parameter propagation
347356

348-
Hierarchical modification of parameters is powerful but sometimes a bit inconvenient. It is also possible to propagate parameters introduced on a high level down in the hierarchy. The following Filter model defines three parameters, `r`, `c` and `v`. The `r` parameter is used to set the resistance of the resistor R: `Map(R=:r)`.
357+
Hierarchical modification of parameters is powerful but sometimes a bit inconvenient.
358+
It is also possible to propagate parameters introduced on a high level down in the hierarchy.
359+
The following Filter model defines three parameters, `r`, `c` and `v`.
360+
The `r` parameter is used to set the resistance of the resistor R: `Map(R=:r)`.
349361

350362
```julia
351363
Filter2 = Model(
@@ -369,9 +381,11 @@ Two separate filters can then be defined with:
369381
TwoFilters = Model( f1 = Filter | Map( r = 10.0, c = 2.0), f2 = Filter )
370382
```
371383

372-
### 2.5.7 Redeclarations
384+
### 2.5.7 Re-declarations
373385

374-
It is possible to reuse a particular model topology by redeclaring the model of particular components. For example, changing the filter `f1` to a voltage divider by changing C from a Capacitor to a Resistor. A predefined definition `redeclare` is used for this purpose.
386+
It is possible to reuse a particular model topology by redeclaring the models of particular components.
387+
For example, changing the filter `f1` to a voltage divider by changing `C` from a Capacitor to a Resistor.
388+
A predefined definition `redeclare` is used for this purpose.
375389

376390
```julia
377391
VoltageDividerAndFilter = TwoFilters | Map(f1 = Map(C = redeclare | Resistor | Map(R = 20.0)))
@@ -384,21 +398,18 @@ The above examples are available in file `FilterCircuit.jl`.
384398

385399
### 2.5.8 Drive train example
386400

387-
A larger example that utilizes most of the previously described features of
388-
Modia is available as `$(Modia.path)/examples/ServoSystem.jl`.
401+
A larger example that utilizes most of the previously described features of Modia is available as `$(Modia.path)/examples/ServoSystem.jl`.
389402
This is a textual (Modia) representation of a Modelica model
390403

391404
![ServoSystem](../../resources/images/ServoSystem.png)
392405

393-
and demonstrates how to build up a hierarchical, multi-domain model consisting
394-
of a servo-system with a load, where the servo-system consists of
395-
an electric motor with a current and speed controller, as well with a more
396-
detailed model of a gearbox.
406+
and demonstrates how to build up a hierarchical, multi-domain model consisting of a servo-system with a load, where the servo-system consists of an electric motor with a current and speed controller, as well with a more detailed model of a gearbox.
397407

398408

399409
## 2.6 Arrays
400410

401-
Model parameters and variables can be arrays. For example a linear state space system
411+
Model parameters and variables can be arrays.
412+
For example a linear state space system
402413

403414
```math
404415
\begin{aligned}
@@ -443,15 +454,15 @@ SecondOrder = Model(
443454
equations = :[sys.u = [1.0]]
444455
)
445456
```
457+
446458
Variables `sys.u` and `sys.y` are vectors with one element each.
447459

448-
Note, `[0; w^2]` is a vector in Julia and not a column matrix
449-
(see the discussion [here](https://discourse.julialang.org/t/construct-a-2-d-column-array/30617)).
460+
Note, `[0; w^2]` is a vector in Julia and not a column matrix (see the discussion [here](https://discourse.julialang.org/t/construct-a-2-d-column-array/30617)).
450461
In order that `B` is defined as column matrix, the function `col(..)` is used.
451462

452463
Array equations remain array equations during symbolic transformation and in the generated code,
453-
so the code is both compact and efficient. In order that this is reasonably possible, the definition
454-
of an array cannot be split in different statements:
464+
so the code is both compact and efficient.
465+
In order that this is reasonably possible, the definition of an array cannot be split in different statements:
455466

456467
```julia
457468
equations = :[ # error, vector v is not defined as one symbol
@@ -460,8 +471,7 @@ equations = :[ # error, vector v is not defined as one symbol
460471
]
461472
```
462473

463-
If scalar equations are needed in which arrays are used, then the arrays have
464-
to be first defined and then elements can be used.
474+
If scalar equations are needed in which arrays are used, then the arrays have to be first defined and then elements can be used.
465475

466476
```julia
467477
v = Var(init=zeros(2)),
@@ -476,8 +486,7 @@ equations = :[
476486

477487
## 2.7 Model libraries
478488

479-
Modia provides a small set of pre-defined model components in directory
480-
`Modia.modelsPath`:
489+
Modia provides a small set of pre-defined model components in directory `Modia.modelsPath`:
481490

482491
- `AllModels.jl` - Include all model libraries
483492
- `Blocks.jl` - Input/output control blocks
@@ -487,11 +496,9 @@ Modia provides a small set of pre-defined model components in directory
487496
- `Translational.jl` - 1D translational, mechanical component models
488497
- [PathPlanning](@ref) - Defining reference trajectories and access them.
489498

490-
These models are included in package `Modia`, but are not exported, so must
491-
be access with `Modia.xxx".
499+
These models are included in package `Modia`, but are not exported, so must be access with `Modia.xxx`.
492500

493-
The circuit of section [2.5.5 Connected models](@ref) can be for example
494-
constructed with these libraries in the following way:
501+
The circuit of section [2.5.5 Connected models](@ref) can be for example constructed with these libraries in the following way:
495502

496503
```julia
497504
using Modia

docs/src/tutorial/Simulation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ modelInstance = @instantiateModel(model;
2626

2727
The macro performs structural and symbolic transformations, generates a function for
2828
calculation of derivatives suitable for use with [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl)
29-
and returns `modelInstance::SimulationModel` that can be used in other functions,
29+
and returns [`SimulationModel`](@ref) that can be used in other functions,
3030
for example to simulate or plot results:
3131

3232
* `model`: model (declarations and equations).
@@ -158,7 +158,7 @@ The option `logStates=true` results in the following output:
158158
159159
This model translates and simulates without problems.
160160
161-
Changing the init-value of `w2` to `1.0` and resimulating:
161+
Changing the init-value of `w2` to `1.0` and re-simulating:
162162
163163
```julia
164164
simulate!(drive1, Tsit5(), stopTime = 1.0, logStates=true, merge = Map(w2=1.0))

0 commit comments

Comments
 (0)