Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PreallocationTools = "0.4.23"
SafeTestsets = "0.1"
SciMLStructures = "1.4.2"
SymbolicIndexingInterface = "0.3.28"
Symbolics = "6.14"
Symbolics = "=6.29.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this pinned to a version?
If at all this is only to set a lower bound, it would be better to not add =. These tend to constraint package resolutions while using with other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ven-k good point. As mentioned in Issue #371 the latest version causes tests to fail. So does it make sense for Symbolics to first be fixed or how to deal with this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbolics 6.30 is yanked from the registry now. The pin can be removed.

Test = "1"
julia = "1.10"

Expand Down
4 changes: 3 additions & 1 deletion src/Thermal/HeatTransfer/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ the component FixedHeatFlow is connected, if parameter `Q_flow` is positive.
end

@equations begin
port.Q_flow ~ -Q_flow * (1 + alpha * (port.T - T_ref))
port.Q_flow ~ ifelse(alpha == 0.0,
-Q_flow, # Simplified equation when alpha is 0
-Q_flow * (1 + alpha * (port.T - T_ref)))
end
end

Expand Down
27 changes: 27 additions & 0 deletions test/Thermal/thermal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,30 @@ end
zeros(length(sol[collector.port_b.Q_flow]))
@test sol[collector.port_b.T] == sol[collector.port_a1.T] == sol[collector.port_a2.T]
end

@testset "FixedHeatFlow with alpha=0.0 test" begin
@mtkmodel TestModel begin

@components begin
temp = FixedTemperature(T=300)
heatflow = FixedHeatFlow(Q_flow=-1.0)
wall = ThermalResistor(R=1)
end

@equations begin
connect(temp.port, wall.port_a)
connect(wall.port_b, heatflow.port)
end

end

@info "Building a FixedHeatFlow with alpha=0.0"
@mtkbuild test_model = TestModel()
prob = ODEProblem(test_model, Pair[], (0, 10.0))
sol = solve(prob)

heat_flow = sol[test_model.heatflow.port.Q_flow]

@test SciMLBase.successful_retcode(sol) # Ensure the simulation is successful
@test all(isapprox.(heat_flow, 1.0, rtol=1e-6)) # Heat flow value should be equal to the fixed value defined
end
Loading