Skip to content

Commit 636b8a0

Browse files
committed
LanguageTool
1 parent a26b4d4 commit 636b8a0

File tree

10 files changed

+64
-49
lines changed

10 files changed

+64
-49
lines changed

docs/src/connectors/connections.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Introduction
22

3-
In Physical Network Acausal modeling each physical domain must define a **connector** to combine model components. Each physical domain **connector** defines a minimum of 2 variables, one which is called a *Through* variable, and one which is called an *Across* variable. Both Modelica and SimScape define these variables in the same way:
3+
In Physical Network Acausal modeling, each physical domain must define a **connector** to combine model components. Each physical domain **connector** defines a minimum of 2 variables, one which is called a *Through* variable, and one which is called an *Across* variable. Both Modelica and SimScape define these variables in the same way:
44

55
- [Modelica Connectors](https://mbe.modelica.university/components/connectors/#acausal-connection)
66
- [SimScape Connectors](https://www.mathworks.com/help/simscape/ug/basic-principles-of-modeling-physical-networks.html#bq89sba-6)
77

8-
However, the standard libraries differ on the selection of the Across variable for the Mechanical Translation and Rotation libraries, Modelica choosing position and angle and SimScape choosing velocity and angular velocity, respectively for Translation and Rotation. Modelica describes their decision [here](https://mbe.modelica.university/components/connectors/simple_domains/). In summary they would like to provide less integration in the model to avoid lossy numerical behavior, but this decision assumes the lowest order derivative is needed by the model. Numerically it is possible to define the connector either way, but there are some consequences to this decision, and therefore we will study them in detail here as they relate to ModelingToolkit.
8+
However, the standard libraries differ on the selection of the Across variable for the Mechanical Translation and Rotation libraries, Modelica choosing position and angle and SimScape choosing velocity and angular velocity, respectively for Translation and Rotation. Modelica describes their decision [here](https://mbe.modelica.university/components/connectors/simple_domains/). In summary, they would like to provide less integration in the model to avoid lossy numerical behavior, but this decision assumes the lowest order derivative is needed by the model. Numerically it is possible to define the connector either way, but there are some consequences of this decision, and therefore we will study them in detail here as they relate to ModelingToolkit.
99

1010
# Through and Across Variable Theory
1111

1212
### General
1313

14-
The idea behind the selection of the **through** variable is that it should be a time derivative of some conserved quantity. The conserved quantity should be expressed by the **across** variable. In general terms the physical system is given by
14+
The idea behind the selection of the **through** variable is that it should be a time derivative of some conserved quantity. The conserved quantity should be expressed by the **across** variable. In general terms, the physical system is given by
1515

1616
- Energy Dissipation & Flow:
1717

@@ -24,7 +24,7 @@ The idea behind the selection of the **through** variable is that it should be a
2424

2525
### Electrical
2626

27-
For the Electrical domain the across variable is *voltage* and the through variable *current*. Therefore
27+
For the Electrical domain, the across variable is *voltage* and the through variable *current*. Therefore
2828

2929
- Energy Dissipation:
3030

@@ -60,7 +60,7 @@ The diagram here shows the similarity of problems in different physical domains.
6060

6161
### Translational Connector using *Position* Across Variable
6262

63-
Now, if we choose *position* for the across variable, a similar relationship can be established, but the patern must be broken.
63+
Now, if we choose *position* for the across variable, a similar relationship can be established, but the pattern must be broken.
6464

6565
- Energy Dissipation:
6666

@@ -109,7 +109,7 @@ println.(equations(sys))
109109
nothing # hide
110110
```
111111

112-
The solution shows what we would expect, a non-linear disipation of voltage and releated decrease in current flow...
112+
The solution shows what we would expect, a non-linear dissipation of voltage and related decrease in current flow
113113

114114
```@example connections
115115
prob = ODEProblem(sys, [1.0], (0, 10.0), [])
@@ -149,7 +149,7 @@ println.(full_equations(sys))
149149
nothing # hide
150150
```
151151

152-
As expected we have a similar solution...
152+
As expected, we have a similar solution
153153

154154
```@example connections
155155
prob = ODEProblem(sys, [], (0, 10.0), [])
@@ -162,7 +162,7 @@ plot(p1, p2)
162162

163163
#### Across Variable = position
164164

165-
Now, let's consider the position based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).
165+
Now, let's consider the position-based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).
166166

167167
```@example connections
168168
const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition
@@ -197,7 +197,7 @@ plot(p1, p2, p3)
197197

198198
The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:
199199

200-
1. the `Mass` component will add the position variable when the `s_0` parameter is used to set an initial position. Otherwise the position is not tracked by the component.
200+
1. the `Mass` component will add the position variable when the `s_0` parameter is used to set an initial position. Otherwise, the component does not track the position.
201201

202202
```julia
203203
@named body = TV.Mass(m = 1, v_0 = 1, s_0 = 0)
@@ -212,15 +212,15 @@ Either option will produce the same result regardless of which across variable i
212212

213213
## Initialization
214214

215-
The main difference between `ModelingToolkitStandardLibrary.Mechanical.Translational` and `ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition` is how they are initialized. In the `ModelingToolkitStandardLibrary` initialization parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.
215+
The main difference between `ModelingToolkitStandardLibrary.Mechanical.Translational` and `ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition` is how they are initialized. In the `ModelingToolkitStandardLibrary` initialization, parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.
216216

217217
![Example Mechanical Model](model.png)
218218

219-
In this problem we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.
219+
In this problem, we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.
220220

221221
#### Damper
222222

223-
The damper will connect the flange/flange 1 (`flange_a`) to the mass, and flange/flange 2 (`flange_b`) to the fixed point. For both position and velocity based domains, we set the damping constant `d=1` and `v_a_0=1` and leave the default for `v_b_0` at 0. For the position domain we also need to set the initial positions for `flange_a` and `flange_b`.
223+
The damper will connect the flange/flange 1 (`flange_a`) to the mass, and flange/flange 2 (`flange_b`) to the fixed point. For both position- and velocity-based domains, we set the damping constant `d=1` and `v_a_0=1` and leave the default for `v_b_0` at 0. For the position domain, we also need to set the initial positions for `flange_a` and `flange_b`.
224224

225225
```@example connections
226226
@named dv = TV.Damper(d = 1, v_a_0 = 1)
@@ -230,7 +230,7 @@ nothing # hide
230230

231231
#### Spring
232232

233-
The spring will connect the flange/flange 1 (`flange_a`) to the mass, and flange/flange 2 (`flange_b`) to the fixed point. For both position and velocity based domains, we set the spring constant `k=1`. The velocity domain then requires the initial velocity `v_a_0` and initial spring stretch `delta_s_0`. The position domain instead needs the initial positions for `flange_a` and `flange_b` and the natural spring length `l`.
233+
The spring will connect the flange/flange 1 (`flange_a`) to the mass, and flange/flange 2 (`flange_b`) to the fixed point. For both position- and velocity-based domains, we set the spring constant `k=1`. The velocity domain then requires the initial velocity `v_a_0` and initial spring stretch `delta_s_0`. The position domain instead needs the initial positions for `flange_a` and `flange_b` and the natural spring length `l`.
234234

235235
```@example connections
236236
@named sv = TV.Spring(k = 1, v_a_0 = 1, delta_s_0 = 1)
@@ -240,7 +240,7 @@ nothing # hide
240240

241241
#### Mass
242242

243-
For both position and velocity based domains, we set the mass `m=1` and initial velocity `v_0=1`. Like the damper, the position domain requires the position initial conditions set as well.
243+
For both position- and velocity-based domains, we set the mass `m=1` and initial velocity `v_0=1`. Like the damper, the position domain requires the position initial conditions set as well.
244244

245245
```@example connections
246246
@named bv = TV.Mass(m = 1, v_0 = 1)
@@ -250,7 +250,7 @@ nothing # hide
250250

251251
#### Fixed
252252

253-
Here the velocity domain requires no initial condition, but for our model to work as defined we must set the position domain component to the correct intital position.
253+
Here the velocity domain requires no initial condition, but for our model to work as defined we must set the position domain component to the correct initial position.
254254

255255
```@example connections
256256
@named gv = TV.Fixed()
@@ -260,9 +260,9 @@ nothing # hide
260260

261261
### Comparison
262262

263-
As can be seen, the position based domain requires more initial condition information to be properly defined since the absolute position information is required. Thereore based on the model being described, it may be more natural to choose one domain over the other.
263+
As can be seen, the position-based domain requires more initial condition information to be properly defined, since the absolute position information is required. Therefore, based on the model being described, it may be more natural to choose one domain over the other.
264264

265-
Let's define a quick function to simplify and solve the 2 different systems. Note we will solve with a fixed time step and a set tolerance to compare the numerical differences.
265+
Let's define a quick function to simplify and solve the 2 different systems. Note, we will solve with a fixed time step and a set tolerance to compare the numerical differences.
266266

267267
```@example connections
268268
function simplify_and_solve(damping, spring, body, ground)
@@ -305,7 +305,7 @@ plot!(solv, idxs = [bv.v])
305305
plot!(solp, idxs = [bp.v])
306306
```
307307

308-
But, what if we wanted to plot the mass position? This is easy for the position based domain, we have the state `bp₊s(t)`, but for the velocity based domain we have `sv₊delta_s(t)` which is the spring stretch. To get the absolute position we add the spring natrual length (1m) and the fixed position (1m). As can be seen, we then get the same result.
308+
But, what if we wanted to plot the mass position? This is easy for the position-based domain, we have the state `bp₊s(t)`, but for the velocity-based domain we have `sv₊delta_s(t)` which is the spring stretch. To get the absolute position, we add the spring natural length (1m) and the fixed position (1m). As can be seen, we then get the same result.
309309

310310
```@example connections
311311
plot(ylabel = "mass position [m]")
@@ -315,9 +315,9 @@ plot!(solp, idxs = [bp.s])
315315

316316
So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.
317317

318-
## Acuracy
318+
## Accuracy
319319

320-
One may ask then what is the trade off in terms of numerical acuracy? When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are
320+
One may then ask, what the trade-off in terms of numerical accuracy is. When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are
321321

322322
```math
323323
\begin{aligned}
@@ -335,7 +335,7 @@ m \cdot \dot{v} + d \cdot v + k \cdot (s - s_{b_0} - l) = 0 \\
335335
\end{aligned}
336336
```
337337

338-
By definition the spring stretch is
338+
By definition, the spring stretch is
339339

340340
```math
341341
\Delta s = s - s_{b_0} - l

docs/src/index.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# ModelingToolkitStandardLibrary.jl
22

33
ModelingToolkitStandardLibrary.jl is a standard library for the
4-
[ModelingToolkit](https://docs.sciml.ai/ModelingToolkit/stable/) acasual modeling system.
4+
[ModelingToolkit](https://docs.sciml.ai/ModelingToolkit/stable/) acausal modeling system.
55

66
## Installation
77

8-
Assuming that you already have Julia correctly installed, it suffices to import
9-
ModelingToolkitStandardLibrary.jl in the standard way:
8+
To install ModelingToolkitStandardLibrary.jl, use the Julia package manager:
109

1110
```julia
12-
import Pkg;
13-
Pkg.add("ModelingToolkitStandardLibrary");
11+
using Pkg
12+
Pkg.add("ModelingToolkitStandardLibrary")
1413
```
1514

1615
## Tutorials
@@ -30,6 +29,22 @@ The following are the constituant libraries of the ModelingToolkit Standard Libr
3029
- [Magnetic Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/magnetic/)
3130
- [Thermal Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/thermal/)
3231

32+
## Contributing
33+
34+
- Please refer to the
35+
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
36+
for guidance on PRs, issues, and other matters relating to contributing to SciML.
37+
38+
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
39+
- There are a few community forums:
40+
41+
+ The #diffeq-bridged and #sciml-bridged channels in the
42+
[Julia Slack](https://julialang.org/slack/)
43+
+ The #diffeq-bridged and #sciml-bridged channels in the
44+
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
45+
+ On the [Julia Discourse forums](https://discourse.julialang.org)
46+
+ See also [SciML Community page](https://sciml.ai/community/)
47+
3348
## Reproducibility
3449

3550
```@raw html

docs/src/tutorials/custom_component.md

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

33
In this tutorial, the creation of a custom component is demonstrated via the [Chua's circuit](https://en.wikipedia.org/wiki/Chua%27s_circuit).
4-
The circuit is a simple circuit that shows chaotic behaviour.
5-
Except for a non-linear resistor every other component already is part of `ModelingToolkitStandardLibrary.Electrical`.
4+
The circuit is a simple circuit that shows chaotic behavior.
5+
Except for a non-linear resistor, every other component already is part of `ModelingToolkitStandardLibrary.Electrical`.
66

77
First, we need to make some imports.
88

docs/src/tutorials/dc_motor_pi.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# DC Motor with PI-controller
22

3-
In this example a PI-controller is setup for speed control of a DC-motor. An equivalent circuit diagram is depicted below.
3+
In this example, a PI-controller is set up for speed control of a DC-motor. An equivalent circuit diagram is depicted below.
44

55
![DC-motor](https://user-images.githubusercontent.com/50108075/196108356-0e8605e3-61a9-4006-8559-786252e55928.png)
66

77
## Modeling and simulation
88

9-
The electrical part consists of a resistance and inductance. The coupling between the electrical and rotational domain is done via an electro motive force (EMF) component. The voltage across the EMF is proportional to the angular velocity and the current is proportional to the torque. On the mechanical side viscous friction in e.g. a bearing and the inertia of the shaft is modelled.
9+
The electrical part consists of a resistance and inductance. The coupling between the electrical and rotational domain is done via an electro-motive force (EMF) component. The voltage across the EMF is proportional to the angular velocity and the current is proportional to the torque. On the mechanical side, viscous friction in, e.g., a bearing and the inertia of the shaft is modelled.
1010

11-
A PI-controller with anti windup measure should be used as a speed controller. A simulation is performed to verify the tracking performance of the controller and the disturbance rejection capabilities.
11+
A PI-controller with anti-windup measure should be used as a speed controller. A simulation is performed to verify the tracking performance of the controller and the disturbance rejection capabilities.
1212

13-
First the needed packages are imported and the parameters of the model defined.
13+
First, the needed packages are imported and the parameters of the model defined.
1414

1515
```@example dc_motor_pi
1616
using ModelingToolkit
@@ -84,7 +84,7 @@ nothing # hide
8484
```
8585

8686
Now the model can be simulated. Typical rotational mechanical systems are described via `DAE`
87-
(differential algebraic equations), however in this case ModelingToolkit can simplify the model enough
87+
(differential algebraic equations), however in this case, ModelingToolkit can simplify the model enough
8888
so that it can be represented as a system of `ODEs` (ordinary differential equations).
8989

9090
```@example dc_motor_pi
@@ -127,7 +127,7 @@ bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
127127
plotphase = false)
128128
```
129129

130-
In a similar fashion, we may compute the loop-transfer function and plot its Nyquist curve
130+
Similarly, we may compute the loop-transfer function and plot its Nyquist curve
131131

132132
```@example dc_motor_pi
133133
matrices_L, simplified_sys = Blocks.get_looptransfer(model, :y)

docs/src/tutorials/thermal_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This example demonstrates the thermal response of two masses connected by a conducting element.
44
The two masses have the same heat capacity but different initial temperatures (`T1=100 [°C]`, `T2=0 [°C]`).
5-
The mass with the higher temperature will cool off while the mass with the lower temperature heats up.
5+
The mass with the higher temperature will cool off, while the mass with the lower temperature heats up.
66
They will each asymptotically approach the calculated temperature T_final_K that results
77
from dividing the total initial energy in the system by the sum of the heat capacities of each element.
88

src/Blocks/continuous.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
Outputs an approximate derivative of the input. The transfer function of this block is
3030
3131
```
32-
k k
32+
k k
3333
─ - ──────────
3434
T 2 ⎛ 1⎞
3535
T ⋅⎜s + ─⎟
@@ -71,15 +71,15 @@ A first-order filter with a single real pole in `s = -T` and gain `k`. If `lowpa
7171
is given by `Y(s)/U(s) = `
7272
7373
```
74-
k
74+
k
7575
───────
7676
sT + 1
7777
```
7878
7979
and if `lowpass=false`, by
8080
8181
```
82-
sT + 1 - k
82+
sT + 1 - k
8383
──────────
8484
sT + 1
8585
```
@@ -117,7 +117,7 @@ A second-order filter with gain `k`, a bandwidth of `w` rad/s and relative dampi
117117
is given by `Y(s)/U(s) = `
118118
119119
```
120-
k*w^2
120+
k*w^2
121121
─────────────────
122122
s² + 2d*w*s + w^2
123123
```
@@ -196,8 +196,8 @@ Text-book version of a PID-controller without actuator saturation and anti-windu
196196
# Parameters:
197197
198198
- `k`: Gain
199-
- `Ti`: [s] Integrator time constant (Ti>0 required). If set to false no integral action is used.
200-
- `Td`: [s] Derivative time constant (Td>0 required). If set to false no derivative action is used.
199+
- `Ti`: [s] Integrator time constant (Ti>0 required). If set to false, no integral action is used.
200+
- `Td`: [s] Derivative time constant (Td>0 required). If set to false, no derivative action is used.
201201
- `Nd`: [s] Time constant for the derivative approximation (Nd>0 required; Nd=0 is ideal derivative).
202202
- `x_start`: Initial value for the integrator.
203203
- `xd_start`: Initial value for the derivative state.

0 commit comments

Comments
 (0)