Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinOtter committed Jul 27, 2021
2 parents d47eb46 + 0c57392 commit 6c341ee
Show file tree
Hide file tree
Showing 13 changed files with 666 additions and 270 deletions.
267 changes: 161 additions & 106 deletions Manifest.toml

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
name = "ModiaBase"
uuid = "ec7bf1ca-419d-4510-bbab-199861c55244"
authors = ["Hilding Elmqvist <[email protected]>", "Martin Otter <[email protected]>"]
version = "0.7.2-dev"
version = "0.7.3"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
DataFrames = "0.22, 0.21, 0.20, 0.19"
DataStructures = "0.18, 0.17"
DataFrames = "1.2, 1.1, 0.22, 0.21, 0.20, 0.19"
DiffRules = "1.0"
Measurements = "2.5, 2.4, 2.3"
MonteCarloMeasurements = "0.10"
Measurements = "2.6, 2.5, 2.4, 2.3"
MonteCarloMeasurements = "0.10, 0.9"
OrderedCollections = "1.4, 1.3"
TimerOutputs = "0.5"
Unitful = "1.6, 1.5, 1.4, 1.3"
julia = "1.5, 1.6"
julia = "1.6, 1.5"
2 changes: 1 addition & 1 deletion docs/src/TransformationToODEs.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CurrentModule = ModiaBase
StateCategory
ResidualCategory
LinearEquations
LinearEquationsIterator
LinearEquationsIteration
EquationInfo
StateElementInfo
```
20 changes: 19 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,31 @@ julia> ]add Unitful, Measurements, MonteCarloMeasurements, Distributions

## Release Notes

### Version 0.7.3

- Speed improvements for structural and symbolic algorithms.

- Added support for state events, time events and synchronous operators
(positive(), Clock(), after(), pre(), previous(), hold(), initial(), terminal())

- Added support for mixed linear equation systems having Real and Boolean unknowns.

- Simplified code for linear equation systems (while-loop instead of for-loop).

- Added TimerOutputs @timeit instrumentation to the solution of linear equation systems.


### Version 0.7.2

- Support of parameters as hierarchical named tuples.

- Support of array comprehensions.
- Support of array `end` (e.g. A[3:end])

- Support of array end (e.g. A[3:end])

- If one equation cannot be solved for one unknown (e.g. since function call),
try to solve it as linear equation system.

- If variables with init values are explicitly solved for, print warning message
only if log = true (in TinyModia.simulate! an error occurs, if the init value
cannot be respected).
Expand Down
37 changes: 24 additions & 13 deletions src/BLTandPantelides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ using ..BLTandPantelidesUtilities
const log = false

"""
function augmentPath!(G, i, assign, vColour, eColour, vActive)
function augmentPath!(G, i, assign, vColour, eColour, vPassive)
Construction of augmenting path
Reference:
Pantelides, C.: The consistent initialization of differential-algebraic systems. SIAM Journal
of Scientific and Statistical Computing, 9(2), pp. 213–231 (1988).
"""
function augmentPath!(G, i, assign, vColour, eColour, vActive)
function augmentPath!(G, i, assign, vColour, eColour, vPassive)
# returns pathFound
# assign: assign[j] contains the E-node to which V-node j is assigned or 0 if V-node j not assigned
# i: E-node
# vActive: set to false has the same effect as deleting V-node and corresponding edges
# vPassive: set to != 0 has the same effect as deleting V-node and corresponding edges
# j: V-node

if log
Expand All @@ -50,7 +50,7 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)

# If a V-node j exists such that edge (i-j) exists and assign[j] == 0
for j in G[i]
if vActive[j] && assign[j] == 0
if vPassive[j] == 0 && assign[j] == 0
pathFound = true
assign[j] = i
return pathFound
Expand All @@ -59,10 +59,10 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)

# For every j such that edge (i-j) exists and j is uncoloured
for j in G[i]
if vActive[j] && !vColour[j]
if vPassive[j] == 0 && !vColour[j]
vColour[j] = true
k = assign[j]
pathFound = augmentPath!(G, k, assign, vColour, eColour, vActive)
pathFound = augmentPath!(G, k, assign, vColour, eColour, vPassive)

if pathFound
assign[j] = i
Expand All @@ -74,11 +74,11 @@ function augmentPath!(G, i, assign, vColour, eColour, vActive)
end


function checkAssign(assign, VSizes, VTypes, ESizes, ETypes, equationsInfix, variableNames, A, vActive=[a == 0 for a in A])
function checkAssign(assign, VSizes, VTypes, ESizes, ETypes, equationsInfix, variableNames, A, vPassive=A)
println("Checking assignment")
assignmentOK = true
for j in 1:length(assign)
if vActive[j]
if vPassive[j] == 0
i = assign[j]
if i > 0 && VSizes[j] != ESizes[i]
assignmentOK = false
Expand Down Expand Up @@ -114,10 +114,11 @@ function matching(G, M, vActive=fill(true, M))
assign::Array{Int,1} = fill(0, M)
eColour::Array{Bool,1} = fill(false, length(G))
vColour::Array{Bool,1} = fill(false, M)
vPassive::Array{Int,1} = [if va; 0 else 1 end for va in vActive]
for i in 1:length(G)
fill!(eColour, false)
fill!(vColour, false)
pathFound = augmentPath!(G, i, assign, vColour, eColour, vActive)
pathFound = augmentPath!(G, i, assign, vColour, eColour, vPassive)
end
return assign
end
Expand All @@ -142,18 +143,28 @@ of Scientific and Statistical Computing, 9(2), pp. 213–231 (1988).
function pantelides!(G, M, A)
assign::Array{Int,1} = fill(0, M)
B::Array{Int,1} = fill(0, length(G))
eColour::Array{Bool,1} = fill(false, length(G))
vColour::Array{Bool,1} = fill(false, M)
N = length(G)
N2 = N
for k in 1:N2
pathFound = false
i = k
while !pathFound
# Delete all V-nodes with A[.] != 0 and all their incidence edges from the graph
vActive::Array{Bool,1} = [a == 0 for a in A]
# Designate all nodes as "uncoloured"
eColour::Array{Bool,1} = fill(false, length(G))
vColour::Array{Bool,1} = fill(false, M)
pathFound = augmentPath!(G, i, assign, vColour, eColour, vActive)
if length(eColour) == length(G)
fill!(eColour, false)
else
eColour = fill(false, length(G))
end
if length(vColour) == length(M)
fill!(vColour, false)
else
vColour = fill(false, M)
end

pathFound = augmentPath!(G, i, assign, vColour, eColour, A)
if !pathFound
if log
println("\nDifferentiate:")
Expand Down
4 changes: 3 additions & 1 deletion src/Differentiate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ function derivative(ex::Expr, timeInvariants=[])
end
if length(sum) > 1
Expr(:call, :+, sum...)
else
elseif length(sum) == 1
sum[1]
else
0
end
else
:($d * $(derArguments[1]))
Expand Down
Loading

0 comments on commit 6c341ee

Please sign in to comment.