Skip to content

Commit da43555

Browse files
Merge pull request #632 from ArnoStrouwen/LT
[skip ci] LanguageTool 1
2 parents 73072cb + 9741084 commit da43555

File tree

9 files changed

+102
-104
lines changed

9 files changed

+102
-104
lines changed

docs/src/extras/timestepping.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ error is larger than the tolerances, and the step is accepted if
2929

3030
## Integral Controller (Standard Controller)
3131

32-
The proportional control algorithm is the "standard algorithm" for adaptive
32+
The proportional control algorithm is the standard algorithm for adaptive
3333
timestepping. Note that it is not the default in DifferentialEquations.jl
3434
because it is usually awful for performance, but it is explained first because
35-
it is the most widely taught algorithm and others build off of its techniques.
35+
it is the most widely taught algorithm and others build on its techniques.
3636

3737
The control simply changes `dt` proportional to the error. There is an
3838
exponentiation based on the order of the algorithm which goes back to a result
@@ -44,12 +44,12 @@ qtmp = integrator.EEst^(1/(alg_adaptive_order(integrator.alg)+1))/integrator.opt
4444
integrator.dtnew = integrator.dt/q
4545
```
4646

47-
Thus `q` is the scaling factor for `dt`, and it must be between `qmin` and `qmax`.
47+
Thus, `q` is the scaling factor for `dt`, and it must be between `qmin` and `qmax`.
4848
`gamma` is the safety factor, `0.9`, for how much `dt` is decreased below the
49-
theoretical "optimal" value.
49+
theoretical optimal value.
5050

51-
Since proportional control is "jagged", i.e. can cause large changes between
52-
one step to the next, it can effect the stability of explicit methods. Thus
51+
Since proportional control is jagged, i.e. can cause large changes between
52+
one step to the next, it can effect the stability of explicit methods. Thus,
5353
it's only applied by default to low order implicit solvers.
5454

5555
```@docs
@@ -130,7 +130,7 @@ integrator.erracc = max(1e-2,integrator.EEst)
130130
integrator.dt/qacc
131131
```
132132

133-
When it rejects, its the same as the proportional control:
133+
When it rejects, it is the same as the proportional control:
134134

135135
```julia
136136
if integrator.success_iter == 0

docs/src/features/callback_functions.md

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ types can be used to build libraries of extension behavior.
1010
The callback types are defined as follows. There are three primitive callback types: the `ContinuousCallback`, `DiscreteCallback` and the `VectorContinuousCallback`:
1111

1212
- The [`ContinuousCallback`](@ref) is applied when a given continuous *condition function* hits zero. This hitting can happen even within
13-
an integration step and the solver must be able to detect it and adjust the integration step accordingly. This type of callback implements
14-
what is known in other problem solving environments as an *Event*.
13+
an integration step, and the solver must be able to detect it and adjust the integration step accordingly. This type of callback implements
14+
what is known in other problem-solving environments as an *Event*.
1515
- The [`DiscreteCallback`](@ref) is applied when its *condition function* is `true`, but the condition is only evaluated at the end of every
1616
integration step.
17-
- The [`VectorContinuousCallback`](@ref) works like a vector of `ContinuousCallbacks` and lets the user specify a vector of continuous callbacks
18-
each with simultanious rootfinding equations. The effect that is applied is the effect corresponding to the first/earliest condition that is
17+
- The [`VectorContinuousCallback`](@ref) works like a vector of `ContinuousCallbacks` and lets the user specify a vector of continuous callbacks,
18+
each with simultaneous rootfinding equations. The effect that is applied is the effect corresponding to the first (earliest) condition that is
1919
satisfied. A `VectorContinuousCallback` is more efficient than a `CallbackSet` of `ContinuousCallback`s as the number of callbacks grows. As
2020
such, it's a slightly more involved definition which gives better scaling.
2121

@@ -58,7 +58,7 @@ or a `CallbackSet`.
5858
### Note About Saving
5959

6060
When a callback is supplied, the default saving behavior is turned off. This is
61-
because otherwise events would "double save" one of the values. To re-enable
61+
because otherwise, events would double save one of the values. To re-enable
6262
the standard saving behavior, one must have the first `save_positions` value
6363
be true for at least one callback.
6464

@@ -343,10 +343,8 @@ end
343343
```
344344

345345
All we have to do in order to specify the event is to have a function which
346-
should always be positive with an event occurring at 0. For now at least
347-
that's how it's specified. If a generalization is needed we can talk about
348-
this (but it needs to be "root-findable"). For here it's clear that we just
349-
want to check if the ball's height ever hits zero:
346+
should always be positive, with an event occurring at 0.
347+
We thus want to check if the ball's height ever hits zero:
350348

351349
```@example callback4
352350
function condition(u,t,integrator) # Event when event_f(u,t) == 0
@@ -358,7 +356,7 @@ Notice that here we used the values `u` instead of the value from the `integrato
358356
This is because the values `u,t` will be appropriately modified at the interpolation
359357
points, allowing for the rootfinding behavior to occur.
360358

361-
Now we have to say what to do when the event occurs. In this case we just
359+
Now we have to say what to do when the event occurs. In this case, we just
362360
flip the velocity (the second variable)
363361

364362
```@example callback4
@@ -387,8 +385,8 @@ using Plots; plot(sol)
387385

388386
As you can see from the resulting image, DifferentialEquations.jl is smart enough
389387
to use the interpolation to hone in on the time of the event and apply the event
390-
back at the correct time. Thus one does not have to worry about the adaptive timestepping
391-
"overshooting" the event as this is handled for you. Notice that the event macro
388+
back at the correct time. Thus, one does not have to worry about the adaptive timestepping
389+
overshooting the event, as this is handled for you. Notice that the event macro
392390
will save the value(s) at the discontinuity.
393391

394392
The callback is robust to having multiple discontinuities occur. For example,
@@ -428,9 +426,9 @@ plot(sol)
428426

429427
Notice that at the end, the ball is not at `0.0` like the condition would let
430428
you believe, but instead it's at `4.329177480185359e-16`. From the printing
431-
inside of the affect function, we can see that this is the value it had at the
429+
inside the affect function, we can see that this is the value it had at the
432430
event time `t=0.4517539514526232`. Why did the event handling not make it exactly
433-
zero? If you instead would have run the simulation to
431+
zero? If you instead had run the simulation to
434432
`nextfloat(0.4517539514526232) = 0.45175395145262326`, we would see that the
435433
value of `u[1] = -1.2647055847076505e-15`. You can see this by changing the
436434
`rootfind` argument of the callback:
@@ -444,10 +442,10 @@ sol = solve(prob, Tsit5(), callback=floor_event)
444442
sol[end] # [-1.2647055847076505e-15, 0.0]
445443
```
446444

447-
What this means is that there is not 64-bit floating point number `t` such that
445+
What this means is that there is no 64-bit floating-point number `t` such that
448446
the condition is zero! By default, if there is no `t` such that `condition=0`,
449-
then rootfinder defaults to choosing the floating point number exactly before
450-
the exactly before the event (`LeftRootFind`). This way manifold constraints are
447+
then the rootfinder defaults to choosing the floating-point number exactly before
448+
the event (`LeftRootFind`). This way manifold constraints are
451449
preserved by default (i.e. the ball never goes below the floor). However, if you
452450
require that the condition is exactly satisfied after the event, you will want
453451
to add such a change to the `affect!` function. For example, the error correction
@@ -468,7 +466,7 @@ sol = solve(prob, Tsit5(), callback=floor_event)
468466
sol[end] # [0.0,0.0]
469467
```
470468

471-
and now the sticky behavior is perfect to the floating point.
469+
and now the sticky behavior is perfect to the floating-point.
472470

473471
#### Handling Accumulation Points
474472

@@ -496,12 +494,12 @@ sol = solve(prob, Tsit5(), callback=floor_event)
496494
plot(sol)
497495
```
498496

499-
From the readout we can see the ball only bounced 8 times before it went below
500-
the floor, what happened? What happened is floating point error. Because one
501-
cannot guarantee that floating point numbers exist to make the `condition=0`,
497+
From the readout, we can see the ball only bounced 8 times before it went below
498+
the floor, what happened? What happened is floating-point error. Because one
499+
cannot guarantee that floating-point numbers exist to make the `condition=0`,
502500
a heuristic is used to ensure that a zero is not accidentally detected at
503-
`nextfloat(t)` after the simulation restarts (otherwise it would repeatly find
504-
the same event!). However, sooner or later the ability to detect minute floating
501+
`nextfloat(t)` after the simulation restarts (otherwise it would repeatedly find
502+
the same event!). However, sooner or later, the ability to detect minute floating
505503
point differences will crash, and what should be infinitely many bounces finally
506504
misses a bounce.
507505

@@ -510,26 +508,26 @@ This leads to two questions:
510508
1. How can you improve the accuracy of an accumulation calculation?
511509
2. How can you make it gracefully continue?
512510

513-
For (1), note that floating point accuracy is dependent on the current `dt`. If
511+
For (1), note that floating-point accuracy is dependent on the current `dt`. If
514512
you know that an accumulation point is coming, one can use `set_proposed_dt!`
515513
to shrink the `dt` value and help find the next bounce point. You can use
516514
`t - tprev` to know the length of the previous interval for this calculation.
517515
For this example, we can set the proposed `dt` to `(t - tprev)/10` to ensure
518-
an ever increasing accuracy of the check.
516+
an ever-increasing accuracy of the check.
519517

520518
However, at some point we will hit machine epsilon, the value where
521519
`t + eps(t) == t`, so we cannot measure infinitely many bounces and instead will
522-
be limited by the floating point accuracy of our number representation. Using
520+
be limited by the floating-point accuracy of our number representation. Using
523521
alternative number types like
524522
[ArbFloats.jl](https://github.com/JuliaArbTypes/ArbFloats.jl) can allow for this
525-
to be done at very high accuracy, but still not infinite. Thus what we need to
523+
to be done at very high accuracy, but still not infinite. Thus, what we need to
526524
do is determine a tolerance after which we assume the accumulation has been
527-
reached and define the exit behavior. In this case we will say when the
525+
reached and define the exit behavior. In this case, we will say when the
528526
`dt<1e-12`, we are almost at the edge of Float64 accuracy
529527
(`eps(1.0) = 2.220446049250313e-16`), so we will change the position and
530528
velocity to exactly zero.
531529

532-
With these floating point corrections in mind, the accumulation calculations
530+
With these floating-point corrections in mind, the accumulation calculation
533531
looks as follows:
534532

535533
```@example callback4
@@ -557,7 +555,7 @@ sol = solve(prob, Tsit5(), callback=floor_event)
557555
plot(sol)
558556
```
559557

560-
With this corrected version, we see that after 41 bounces the accumulation
558+
With this corrected version, we see that after 41 bounces, the accumulation
561559
point is reached at `t = 1.355261854357056`. To really see the accumulation,
562560
let's zoom in:
563561

@@ -573,11 +571,11 @@ I think Zeno would be proud of our solution.
573571

574572
### Example 2: Terminating an Integration
575573

576-
In many cases you might want to terminate an integration when some condition is
574+
Often, you might want to terminate an integration when some condition is
577575
satisfied. To terminate an integration, use `terminate!(integrator)` as the `affect!`
578576
in a callback.
579577

580-
In this example we will solve the differential equation:
578+
In this example, we will solve the differential equation:
581579

582580
```@example callback4
583581
using DifferentialEquations
@@ -603,9 +601,9 @@ cb = DiscreteCallback(condition,affect!)
603601
sol = solve(prob,Tsit5(),callback=cb)
604602
```
605603

606-
However, in many cases we wish to halt exactly at the point of time that the
607-
condition is satisfied. To do that, we use a continuous callback. The condition
608-
must thus be a function which is zero at the point we want to halt. Thus we
604+
However, we often wish to halt exactly at the point of time that the
605+
condition is satisfied. To achieve that, we use a continuous callback. The condition
606+
must thus be a function which is zero at the point we want to halt. Thus, we
609607
use the following:
610608

611609
```@example callback4
@@ -616,7 +614,7 @@ sol = solve(prob,Tsit5(),callback=cb)
616614
using Plots; plot(sol)
617615
```
618616

619-
Note that this uses rootfinding to approximate the "exact" moment of the crossing.
617+
Note that this uses rootfinding to approximate the exact moment of the crossing.
620618
Analytically we know the value is `pi`, and here the integration terminates at
621619

622620
```@example callback4
@@ -631,7 +629,7 @@ sol = solve(prob,Vern8(),callback=cb,reltol=1e-12,abstol=1e-12)
631629
sol.t[end] # 3.1415926535896035
632630
```
633631

634-
Now say we wish to find the when the first period is over, i.e. we want to ignore
632+
Now say we wish to find when the first period is over, i.e. we want to ignore
635633
the upcrossing and only stop on the downcrossing. We do this by ignoring the
636634
`affect!` and only passing an `affect!` for the second:
637635

@@ -654,8 +652,8 @@ because the first event is an upcrossing.
654652
Another interesting issue is with models of changing sizes. The ability to handle
655653
such events is a unique feature of DifferentialEquations.jl! The problem we would
656654
like to tackle here is a cell population. We start with 1 cell with a protein `X`
657-
which increases linearly with time with rate parameter `α`. Since we are going
658-
to be changing the size of the population, we write the model in the general form:
655+
which increases linearly with time with rate parameter `α`. Since we will
656+
be changing the size of the population, we write the model in the general form:
659657

660658
```@example callback5
661659
const α = 0.3
@@ -719,7 +717,7 @@ plot(sol.t,map((x)->length(x),sol[:]),lw=3,
719717
ylabel="Number of Cells",xlabel="Time")
720718
```
721719

722-
Now let's check-in on a cell. We can still use the interpolation to get a nice
720+
Now let's check in on a cell. We can still use the interpolation to get a nice
723721
plot of the concentration of cell 1 over time. This is done with the command:
724722

725723
```@example callback5
@@ -776,7 +774,7 @@ cb = VectorContinuousCallback(condition,affect!,2)
776774

777775
It is evident that `out[2]` will be zero when `u[3]` (x-coordinate) is either `0.0` or `10.0`. And when that happens, we flip the velocity with some coefficient of restitution (`0.9`).
778776

779-
Completeting rest of the code-
777+
Completing the rest of the code
780778
```@example callback6
781779
u0 = [50.0,0.0,0.0,2.0]
782780
tspan = (0.0,15.0)

docs/src/features/diffeq_arrays.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
In many cases, a standard array may not be enough to fully hold the data for a
44
model. Many of the solvers in DifferentialEquations.jl (only the native Julia
5-
methods) allow you to solve problems on `AbstractArray` types which allow you
6-
to extend the meaning of an array. This page describes some of the `AbstractArray`
5+
methods) allow you to solve problems on `AbstractArray` types, which allow you
6+
to extend the meaning of an array. This page describes some `AbstractArray`
77
types which can be helpful for modeling differential equations problems.
88

99
## ArrayPartitions
@@ -18,8 +18,8 @@ A = ArrayPartition(x::AbstractArray...)
1818
```
1919

2020
where `x` is an array of arrays. Then, `A` will act like a single array, and its
21-
broadcast will be type stable, allowing for it to be used inside of the native Julia
22-
DiffEq solvers in an efficient way. This is a good way to generate an array which
21+
broadcast will be type stable, allowing for it to be efficiently used inside
22+
the native Julia DiffEq solvers. This is a good way to generate an array which
2323
has different units for different parts, or different amounts of precision.
2424

2525
### Usage
@@ -37,7 +37,7 @@ We would have `A.x[1]==y` and `A.x[2]==z`. Broadcasting like `f.(A)` is efficien
3737

3838
### Example: Dynamics Equations
3939

40-
In this example we will show using heterogeneous units in dynamics equations. Our
40+
In this example, we will show using heterogeneous units in dynamics equations. Our
4141
arrays will be:
4242

4343
```@example diffeq_arrays

docs/src/features/diffeq_operator.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DiffEqArrayOperator(A::AbstractMatrix{T},update_func = DEFAULT_UPDATE_FUNC)
3030

3131
`A` is the operator array. `update_func(A,u,p,t)` is the function called by
3232
`update_coefficients!(A,u,p,t)`. If left as its default, then `update_func`
33-
is trivial which signifies `A` is a constant.
33+
is trivial, which signifies `A` is a constant.
3434

3535
### AffineDiffEqOperator
3636

@@ -45,7 +45,7 @@ builds an operator `L = (A1 + A2 + ... An)*u + B1 + B2 + ... + Bm`. `u_cache`
4545
is for designating a type of internal cache for non-allocating evaluation of
4646
`L(du,u,p,t)`. If not given, the function `L(du,u,p,t)` is not available. Note
4747
that in solves which exploit this structure, this function call is not necessary.
48-
It's only used as the fallback in ODE solvers which were not developed for this
48+
It's only used as the fallback in ODE solvers, which were not developed for this
4949
structure.
5050

5151
## Formal Properties of DiffEqOperators
@@ -57,22 +57,22 @@ for it to work in the solvers.
5757

5858
1. Function call and multiplication: `L(du,u,p,t)` for inplace and `du = L(u,p,t)` for
5959
out-of-place, meaning `L*u` and `mul!`.
60-
2. If the operator is not a constant, update it with `(u,p,t)`. A mutating form, i.e.
61-
`update_coefficients!(A,u,p,t)` that changes the internal coefficients, and a
60+
2. If the operator is not a constant, update it with `(u,p,t)`. A mutating form, i.e.,
61+
`update_coefficients!(A,u,p,t)` that changes the internal coefficients, and an
6262
out-of-place form `B = update_coefficients(A,u,p,t)`.
6363
3. `isconstant(A)` trait for whether the operator is constant or not.
6464

6565
### AbstractDiffEqLinearOperator Interface Description
6666

6767
1. `AbstractDiffEqLinearOperator <: AbstractDiffEqOperator`
68-
2. Can absorb under multiplication by a scalar. In all algorithms things like
68+
2. Can absorb under multiplication by a scalar. In all algorithms, things like
6969
`dt*L` show up all the time, so the linear operator must be able to absorb
7070
such constants.
7171
4. `isconstant(A)` trait for whether the operator is constant or not.
72-
5. Optional: `diagonal`, `symmetric`, etc traits from LinearMaps.jl.
72+
5. Optional: `diagonal`, `symmetric`, etc. traits from LinearMaps.jl.
7373
6. Optional: `exp(A)`. Required for simple exponential integration.
7474
7. Optional: `expv(A,u,t) = exp(t*A)*u` and `expv!(v,A::DiffEqOperator,u,t)`
7575
Required for sparse-saving exponential integration.
76-
8. Optional: factorizations. `ldiv!`, `factorize` et. al. This is only required
76+
8. Optional: factorizations. `ldiv!`, `factorize` et al. This is only required
7777
for algorithms which use the factorization of the operator (Crank-Nicolson),
7878
and only for when the default linear solve is used.

0 commit comments

Comments
 (0)