Skip to content

Commit 333d446

Browse files
committed
Fixed bug in StateSelection.jl: If unitless=true, no unit is associated with the tearing variable in the generated AST.
1 parent 29fea08 commit 333d446

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModiaBase"
22
uuid = "ec7bf1ca-419d-4510-bbab-199861c55244"
33
authors = ["Hilding Elmqvist <[email protected]>", "Martin Otter <[email protected]>"]
4-
version = "0.7.6-dev"
4+
version = "0.7.6"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/StateSelection.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,29 +870,34 @@ end
870870

871871

872872
"""
873-
addLinearEquations!(eq::EquationGraph, hasConstantCoefficients::Bool)
873+
addLinearEquations!(eq::EquationGraph, hasConstantCoefficients::Bool, unitless::Bool)
874874
875875
A linear equation system is solved. Push this information to
876876
eq.SortedEquations. Furthermore, generate the AST for a for-loop that builds
877877
and solves a linear equation system A*x = b
878878
from the solved equations and the residual equations,
879879
and push this information to eq.SortedEquations.AST.
880880
"""
881-
function addLinearEquations!(eq::EquationGraph, hasConstantCoefficients::Bool)::Nothing
881+
function addLinearEquations!(eq::EquationGraph, hasConstantCoefficients::Bool, unitless::Bool)::Nothing
882882
# Construct body of for-loop
883883
empty!(eq.AST_aux)
884884
while_body = eq.AST_aux
885885
vTear_names = String[]
886886
vTear_lengths = Int[]
887887

888888
# Assign iteration variables
889-
# v_i = leq.vTear_value[i]
889+
# unitless = false:
890+
# v_i = leq.vTear_value[i]
891+
#
892+
# unitless = true:
893+
# v_i = leq.vTear_value[i]*@u_str($v_unit)
894+
#
890895
vAssigned_names = Any[]
891896
i1 = 0
892897
i2 = 0
893898
for (i,v) in enumerate(eq.vTear)
894899
v_name = eq.fc.var_julia_name(v)
895-
v_unit = eq.fc.var_unit(v)
900+
v_unit = unitless ? "" : eq.fc.var_unit(v)
896901
v_length = eq.fc.var_length(undifferentiated(eq,v))
897902
i1 = i2 + 1
898903
i2 = i1 + v_length - 1
@@ -1392,7 +1397,7 @@ function getSortedAndSolvedAST(G, # Typically ::Vector{Vector{Int}}
13921397
end
13931398

13941399
# Generate AST to build-up and solve linear equation system of the teared equations
1395-
addLinearEquations!(eq, hasConstantCoefficients)
1400+
addLinearEquations!(eq, hasConstantCoefficients, unitless)
13961401

13971402

13981403
else

0 commit comments

Comments
 (0)