Skip to content

Commit

Permalink
Merge branch 'SciML:main' into ag/planar-mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem authored Dec 20, 2023
2 parents 7051dbe + f46cdc0 commit abc9d7f
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "crate-ci/typos"
update-types: ["version-update:semver-patch"]
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Spell Check

on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/[email protected]
4 changes: 4 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default.extend-words]
Nd = "Nd"
nin = "nin"
coul = "coul"
10 changes: 9 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
Aqua = "0.8"
ChainRulesCore = "1"
ControlSystemsBase = "1"
DataInterpolations = "4"
DiffEqBase = "6"
IfElse = "0.1"
LinearAlgebra = "1"
ModelingToolkit = "8.67"
OrdinaryDiffEq = "6"
SafeTestsets = "0.1"
Symbolics = "4.9, 5"
Test = "1"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -28,4 +36,4 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["LinearAlgebra", "OrdinaryDiffEq", "SafeTestsets", "Test", "ControlSystemsBase", "DataInterpolations"]
test = ["Aqua", "LinearAlgebra", "OrdinaryDiffEq", "SafeTestsets", "Test", "ControlSystemsBase", "DataInterpolations"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ the documentation, which contains the unreleased features.

## Libraries

The following are the constituant libraries of the ModelingToolkit Standard Library.
The following are the constituent libraries of the ModelingToolkit Standard Library.

- [Basic Blocks](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/blocks/)
- [Mechanical Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/mechanical/)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Pkg.add("ModelingToolkitStandardLibrary")

## Libraries

The following are the constituant libraries of the ModelingToolkit Standard Library.
The following are the constituent libraries of the ModelingToolkit Standard Library.

- [Basic Blocks](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/blocks/)
- [Mechanical Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/mechanical/)
Expand Down
6 changes: 3 additions & 3 deletions docs/src/tutorials/input_component.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ prob = ODEProblem(sys, [], (0, time[end]))
sol = solve(prob, ImplicitEuler())
```

If we want to run a new data set, this requires building a new `LinearInterpolation` and `ODESystem` followed by running `structural_simplify`, all of which takes time. Therefore, to run serveral pieces of data it's better to re-use an `ODESystem`. The next couple methods will demonstrate how to do this.
If we want to run a new data set, this requires building a new `LinearInterpolation` and `ODESystem` followed by running `structural_simplify`, all of which takes time. Therefore, to run several pieces of data it's better to re-use an `ODESystem`. The next couple methods will demonstrate how to do this.

## Custom Component with External Data

Expand Down Expand Up @@ -105,7 +105,7 @@ Additional code could be added to resolve this issue, for example by using a `Re

## `SampledData` Component

To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `ODESystem` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallize the call to `solve()`.
To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `ODESystem` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.

```julia
function System(; name)
Expand Down Expand Up @@ -146,4 +146,4 @@ sol2 = Ref{ODESolution}()
end
```

Note, in the above example, we can build the system with an empty `SampledData` component, only setting the expected data type: `@named src = SampledData(Float64)`. It's also possible to initialize the component with real sampled data: `@named src = SampledData(data, dt)`. Additionally note that before running an `ODEProblem` using the `SampledData` component, one must be careful about the parameter vector Type. The `SampledData` component contains a `buffer` parameter of type `Parameter`, therefore we must generate the problem using `tofloat=false`. This will initially give a parameter vector of type `Vector{Any}` with a mix of numbers and `Parameter` type. We can convert the vector to a uniform `Parameter` type by running `p = Parameter.(p)`. This will wrap all the single values in a `Parameter` which will be mathmatically equivalent to a `Number`.
Note, in the above example, we can build the system with an empty `SampledData` component, only setting the expected data type: `@named src = SampledData(Float64)`. It's also possible to initialize the component with real sampled data: `@named src = SampledData(data, dt)`. Additionally note that before running an `ODEProblem` using the `SampledData` component, one must be careful about the parameter vector Type. The `SampledData` component contains a `buffer` parameter of type `Parameter`, therefore we must generate the problem using `tofloat=false`. This will initially give a parameter vector of type `Vector{Any}` with a mix of numbers and `Parameter` type. We can convert the vector to a uniform `Parameter` type by running `p = Parameter.(p)`. This will wrap all the single values in a `Parameter` which will be mathematically equivalent to a `Number`.
2 changes: 1 addition & 1 deletion src/Blocks/analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ eqs = [connect(P.output, C.input)
connect(C.output, :plant_input, P.input)]
sys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)
matrices_S, _ = get_sensitivity(sys, :plant_input) # Compute the matrices of a state-space representation of the (input) sensitivity funciton.
matrices_S, _ = get_sensitivity(sys, :plant_input) # Compute the matrices of a state-space representation of the (input) sensitivity function.
matrices_T, _ = get_comp_sensitivity(sys, :plant_input)
```
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ To set the initial state, it's recommended to set the initial condition for `x`,
# Parameters:
- `b`: Numerator polynomial coefficients, e.g., `2s + 3` is specified as `[2, 3]`
- `a`: Denomenator polynomial coefficients, e.g., `s² + 2ωs + ω^2` is specified as `[1, 2ω, ω^2]`
- `a`: Denominator polynomial coefficients, e.g., `s² + 2ωs + ω^2` is specified as `[1, 2ω, ω^2]`
# Connectors:
- `input`
Expand Down
4 changes: 2 additions & 2 deletions src/Electrical/Digital/logic.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@enum Logic Uninitialized=1 ForcingUnknown ForcingZero ForcingOne HighImpedence WeakUnknown WeakZero WeakOne DontCare
@enum Logic Uninitialized=1 ForcingUnknown ForcingZero ForcingOne HighImpedance WeakUnknown WeakZero WeakOne DontCare

const U = Uninitialized
const X = ForcingUnknown
const F0 = ForcingZero
const F1 = ForcingOne
const Z = HighImpedence
const Z = HighImpedance
const W = WeakUnknown
const L = WeakZero
const H = WeakOne
Expand Down
2 changes: 1 addition & 1 deletion src/Hydraulic/IsothermalCompressible/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ dm ────► │ │ area
name)
@assert(N>=0,
"the Tube component must be defined with 0 or more segments (i.e. N>=0), found N=$N")
@assert (direction == +1)||(direction == -1) "direction arument must be +/-1, found $direction"
@assert (direction == +1)||(direction == -1) "direction argument must be +/-1, found $direction"

#TODO: How to set an assert effective_length >= length ??
pars = @parameters begin
Expand Down
2 changes: 1 addition & 1 deletion src/ModelingToolkitStandardLibrary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Omits the check expression if the argument `J` is symbolic.
"""
macro symcheck(ex)
ex.args[1].head === :call ||
error("Expected an expresion on the form sym > val || error()")
error("Expected an expression on the form sym > val || error()")
sym = ex.args[1].args[2]
quote
_issymbolic(x) = !(unwrap(x) isa Real)
Expand Down
2 changes: 1 addition & 1 deletion test/Blocks/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Test

#=
Testing strategy:
The general strategy is to test systems using simple intputs where the solution
The general strategy is to test systems using simple inputs where the solution
is known on closed form. For algebraic systems (without differential variables),
an integrator with a constant input is often used together with the system under test.
=#
Expand Down
2 changes: 1 addition & 1 deletion test/Blocks/test_analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ lsys = sminreal(ss(matrices...))

matrices_So, _ = get_sensitivity(sys_outer, :inner_plant_output)
lsyso = sminreal(ss(matrices_So...))
@test lsys == lsyso || lsys == -1 * lsyso * (-1) # Output and input sensitivites are equal for SISO systems
@test lsys == lsyso || lsys == -1 * lsyso * (-1) # Output and input sensitivities are equal for SISO systems

## A more complicated test case
using ModelingToolkit, OrdinaryDiffEq, LinearAlgebra
Expand Down
2 changes: 1 addition & 1 deletion test/Electrical/digital.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using OrdinaryDiffEq: ReturnCode.Success
@test typeof(logic.logic) == Vector{Logic}
@test get_logic_level(logic) == [1, 6, 2, 4]

# Predefiend logic vectors
# Predefined logic vectors
@test std_ulogic.logic == [U, X, F0, F1, Z, W, L, H, DC]
@test UX01.logic == [U, X, F0, F1]
@test UX01Z.logic == [U, X, F0, F1, Z]
Expand Down
11 changes: 11 additions & 0 deletions test/qa.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using ModelingToolkitStandardLibrary, Aqua
@testset "Aqua" begin
Aqua.find_persistent_tasks_deps(ModelingToolkitStandardLibrary)
Aqua.test_ambiguities(ModelingToolkitStandardLibrary, recursive = false)
Aqua.test_deps_compat(ModelingToolkitStandardLibrary)
Aqua.test_piracies(ModelingToolkitStandardLibrary)
Aqua.test_project_extras(ModelingToolkitStandardLibrary)
Aqua.test_stale_deps(ModelingToolkitStandardLibrary)
Aqua.test_unbound_args(ModelingToolkitStandardLibrary)
Aqua.test_undefined_exports(ModelingToolkitStandardLibrary)
end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using SafeTestsets

@safetestset "Quality Assurance" begin
include("qa.jl")
end

# Blocks
@safetestset "Blocks: math" begin
include("Blocks/math.jl")
Expand Down

0 comments on commit abc9d7f

Please sign in to comment.