Skip to content

Commit

Permalink
Merge branch 'master' into recompile
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Sep 11, 2023
2 parents 4c1545e + 66c3627 commit 5b58e4d
Show file tree
Hide file tree
Showing 37 changed files with 532 additions and 405 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: '1'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
- {user: SciML, repo: MethodOfLines.jl, group: DAE}
- {user: ai4energy, repo: Ai4EComponentLib.jl, group: Downstream}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- name: Clone Downstream
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ matrix.package.user }}/${{ matrix.package.repo }}
path: downstream
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- '1'
- '1.6'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- This repository follows the [SciMLStyle](https://github.com/SciML/SciMLStyle) and the SciML [ColPrac](https://github.com/SciML/ColPrac).
- Please run `using JuliaFormatter, ModelingToolkit; format(joinpath(dirname(pathof(ModelingToolkit)), ".."))` before commiting.
- Please run `using JuliaFormatter, ModelingToolkit; format(joinpath(dirname(pathof(ModelingToolkit)), ".."))` before committing.
- Add tests for any new features.
7 changes: 4 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
version = "8.64.0"
version = "8.68.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down Expand Up @@ -32,6 +32,7 @@ MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
Expand Down Expand Up @@ -79,6 +80,7 @@ Latexify = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16"
MLStyle = "0.4.17"
MacroTools = "0.5"
NaNMath = "0.3, 1"
OrdinaryDiffEq = "6"
RecursiveArrayTools = "2.3"
Reexport = "0.2, 1"
RuntimeGeneratedFunctions = "0.5.9"
Expand Down Expand Up @@ -108,7 +110,6 @@ NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationMOI = "fd9f6733-72f4-499f-8506-86b2bdd0dea1"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Expand All @@ -121,4 +122,4 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsMTK", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq"]
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsMTK", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq"]
2 changes: 1 addition & 1 deletion docs/src/basics/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ We can solve this problem by using the `missing_variable_defaults()` function
prob = ODEProblem(sys, ModelingToolkit.missing_variable_defaults(sys), (0,1))
```

This function provides 0 for the default values, which is a safe assumption for dummy derivatives of most models. However, the 2nd arument allows for a different default value or values to be used if needed.
This function provides 0 for the default values, which is a safe assumption for dummy derivatives of most models. However, the 2nd argument allows for a different default value or values to be used if needed.

```
julia> ModelingToolkit.missing_variable_defaults(sys, [1,2,3])
Expand Down
2 changes: 1 addition & 1 deletion src/ModelingToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ abstract type AbstractOptimizationSystem <: AbstractTimeIndependentSystem end

function independent_variable end

# this has to be included early to deal with depency issues
# this has to be included early to deal with dependency issues
include("structural_transformation/bareiss.jl")
function complete end
function var_derivative! end
Expand Down
6 changes: 3 additions & 3 deletions src/bipartite_graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ Essentially the graph adapter performs two largely orthogonal functions
1. It pairs an undirected bipartite graph with a matching of the destination vertex.
This matching is used to induce an orientation on the otherwise undirected graph:
Matched edges pass from destination to source [source to desination], all other edges
Matched edges pass from destination to source [source to destination], all other edges
pass in the opposite direction.
2. It exposes the graph view obtained by contracting the destination [source] vertices
Expand All @@ -632,7 +632,7 @@ graph is acyclic.
# Hypergraph interpretation
Consider the bipartite graph `B` as the incidence graph of some hypergraph `H`.
Note that a maching `M` on `B` in the above sense is equivalent to determining
Note that a matching `M` on `B` in the above sense is equivalent to determining
an (1,n)-orientation on the hypergraph (i.e. each directed hyperedge has exactly
one head, but any arbitrary number of tails). In this setting, this is simply
the graph formed by expanding each directed hyperedge into `n` ordinary edges
Expand Down Expand Up @@ -685,7 +685,7 @@ function Base.iterate(c::CMONeighbors{false}, (l, state...))
r === nothing && return nothing
# If this is a matched edge, skip it, it's reversed in the induced
# directed graph. Otherwise, if there is no matching for this destination
# edge, also skip it, since it got delted in the contraction.
# edge, also skip it, since it got deleted in the contraction.
vsrc = c.g.matching[r[1]]
if vsrc === c.v || !isa(vsrc, Int)
state = (r[2],)
Expand Down
8 changes: 4 additions & 4 deletions src/inputoutput.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ end
same_or_inner_namespace(u, var)
Determine whether `var` is in the same namespace as `u`, or a namespace internal to the namespace of `u`.
Example: `sys.u ~ sys.inner.u` will bind `sys.inner.u`, but `sys.u` remains an unbound, external signal. The namepsaced signal `sys.inner.u` lives in a namspace internal to `sys`.
Example: `sys.u ~ sys.inner.u` will bind `sys.inner.u`, but `sys.u` remains an unbound, external signal. The namespaced signal `sys.inner.u` lives in a namespace internal to `sys`.
"""
function same_or_inner_namespace(u, var)
nu = get_namespace(u)
nv = get_namespace(var)
nu == nv || # namespaces are the same
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namepsace to nu
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namespace to nu
occursin('', string(getname(var))) &&
!occursin('', string(getname(u))) # or u is top level but var is internal
end
Expand All @@ -127,7 +127,7 @@ function inner_namespace(u, var)
nu = get_namespace(u)
nv = get_namespace(var)
nu == nv && return false
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namepsace to nu
startswith(nv, nu) || # or nv starts with nu, i.e., nv is an inner namespace to nu
occursin('', string(getname(var))) &&
!occursin('', string(getname(u))) # or u is top level but var is internal
end
Expand Down Expand Up @@ -177,7 +177,7 @@ f_ip : (xout,x,u,p,t) -> nothing
The return values also include the remaining states and parameters, in the order they appear as arguments to `f`.
If `disturbance_inputs` is an array of variables, the generated dynamics function will preserve any state and dynamics associated with distrubance inputs, but the distrubance inputs themselves will not be included as inputs to the generated function. The use case for this is to generate dynamics for state observers that estimate the influence of unmeasured disturbances, and thus require state variables for the disturbance model, but without disturbance inputs since the disturbances are not available for measurement.
If `disturbance_inputs` is an array of variables, the generated dynamics function will preserve any state and dynamics associated with disturbance inputs, but the disturbance inputs themselves will not be included as inputs to the generated function. The use case for this is to generate dynamics for state observers that estimate the influence of unmeasured disturbances, and thus require state variables for the disturbance model, but without disturbance inputs since the disturbances are not available for measurement.
See [`add_input_disturbance`](@ref) for a higher-level interface to this functionality.
# Example
Expand Down
6 changes: 3 additions & 3 deletions src/structural_transformation/bareiss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ else
function Base.swapcols!(A::AbstractSparseMatrixCSC, i, j)
i == j && return

# For simplicitly, let i denote the smaller of the two columns
# For simplicity, let i denote the smaller of the two columns
j < i && @swap(i, j)

colptr = getcolptr(A)
Expand Down Expand Up @@ -72,7 +72,7 @@ else
return nothing
end
function swaprows!(A::AbstractSparseMatrixCSC, i, j)
# For simplicitly, let i denote the smaller of the two rows
# For simplicity, let i denote the smaller of the two rows
j < i && @swap(i, j)

rows = rowvals(A)
Expand Down Expand Up @@ -184,7 +184,7 @@ const bareiss_virtcolswap = ((M, i, j) -> nothing, swaprows!,
Perform Bareiss's fraction-free row-reduction algorithm on the matrix `M`.
Optionally, a specific pivoting method may be specified.
swap_strategy is an optional argument that determines how the swapping of rows and coulmns is performed.
swap_strategy is an optional argument that determines how the swapping of rows and columns is performed.
bareiss_colswap (the default) swaps the columns and rows normally.
bareiss_virtcolswap pretends to swap the columns which can be faster for sparse matrices.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/structural_transformation/partial_state_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function dummy_derivative_graph!(state::TransformationState, jac = nothing;
dummy_derivative_graph!(state.structure, var_eq_matching, jac, state_priority, log)
end

function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, jac,
state_priority, ::Val{log} = Val(false)) where {log}
function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, jac = nothing,
state_priority = nothing, ::Val{log} = Val(false)) where {log}
@unpack eq_to_diff, var_to_diff, graph = structure
diff_to_eq = invview(eq_to_diff)
diff_to_var = invview(var_to_diff)
Expand Down Expand Up @@ -209,7 +209,7 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
J = nothing
else
_J = jac(eqs, vars)
# only accecpt small intergers to avoid overflow
# only accept small integers to avoid overflow
is_all_small_int = all(_J) do x′
x = unwrap(x′)
x isa Number || return false
Expand Down
4 changes: 2 additions & 2 deletions src/structural_transformation/symbolics_tearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function full_equations(sys::AbstractSystem; simplify = false)
if rhs isa Symbolic
return 0 ~ rhs
else # a number
error("tearing failled because the system is singular")
error("tearing failed because the system is singular")
end
end
eq
Expand Down Expand Up @@ -194,7 +194,7 @@ function to_mass_matrix_form(neweqs, ieq, graph, fullvars, isdervar::F,
return (new_lhs ~ new_rhs), invview(var_to_diff)[dervar]
else # a number
if abs(rhs) > 100eps(float(rhs))
@warn "The equation $eq is not consistent. It simplifed to 0 == $rhs."
@warn "The equation $eq is not consistent. It simplified to 0 == $rhs."
end
return nothing
end
Expand Down
Loading

0 comments on commit 5b58e4d

Please sign in to comment.