Skip to content

Commit a8f0540

Browse files
authored
Merge pull request #213 from ufechner7/next-step
Make next_step! return nothing
2 parents 4fdcf4c + 3813075 commit a8f0540

10 files changed

+50
-46
lines changed

Manifest-v1.10.toml.default

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.9"
44
manifest_format = "2.0"
5-
project_hash = "e060360f8cac442cf470fedd0c1378b00cf639db"
5+
project_hash = "e5116e83aee3763e3ebd89b0de5522b585f68fec"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "e2478490447631aedba0823d4d7a80b2cc8cdb32"
@@ -144,9 +144,9 @@ version = "1.1.0"
144144
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
145145

146146
[[deps.Bijections]]
147-
git-tree-sha1 = "6aaafea90a56dc1fc8cbc15e3cf26d6bc81eb0a3"
147+
git-tree-sha1 = "a2d308fcd4c2fb90e943cf9cd2fbfa9c32b69733"
148148
uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04"
149-
version = "0.1.10"
149+
version = "0.2.2"
150150

151151
[[deps.BitIntegers]]
152152
deps = ["Random"]
@@ -328,9 +328,9 @@ uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
328328
version = "2.5.0"
329329

330330
[[deps.ConstructionBase]]
331-
git-tree-sha1 = "76219f1ed5771adbb096743bff43fb5fdd4c1157"
331+
git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb"
332332
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
333-
version = "1.5.8"
333+
version = "1.6.0"
334334
weakdeps = ["IntervalSets", "LinearAlgebra", "StaticArrays"]
335335

336336
[deps.ConstructionBase.extensions]
@@ -889,9 +889,9 @@ version = "0.3.8"
889889

890890
[[deps.KiteUtils]]
891891
deps = ["Arrow", "CSV", "DocStringExtensions", "LinearAlgebra", "OrderedCollections", "Parameters", "Parsers", "Pkg", "PrecompileTools", "RecursiveArrayTools", "ReferenceFrameRotations", "Rotations", "StaticArrays", "StructArrays", "StructTypes", "YAML"]
892-
git-tree-sha1 = "824fc2f35d5afd6332d28c69fe9e31e11267e934"
892+
git-tree-sha1 = "ef1ab34bdb8c1bcf06f99b4364cae5df1be6936a"
893893
uuid = "90980105-b163-44e5-ba9f-8b1c83bb0533"
894-
version = "0.10.7"
894+
version = "0.10.10"
895895

896896
[[deps.Krylov]]
897897
deps = ["LinearAlgebra", "Printf", "SparseArrays"]
@@ -995,9 +995,9 @@ weakdeps = ["LineSearches"]
995995

996996
[[deps.LineSearches]]
997997
deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"]
998-
git-tree-sha1 = "e4c3be53733db1051cc15ecf573b1042b3a712a1"
998+
git-tree-sha1 = "4adee99b7262ad2a1a4bbbc59d993d24e55ea96f"
999999
uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
1000-
version = "7.3.0"
1000+
version = "7.4.0"
10011001

10021002
[[deps.LinearAlgebra]]
10031003
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
@@ -1333,9 +1333,9 @@ version = "1.6.0"
13331333

13341334
[[deps.OrdinaryDiffEqCore]]
13351335
deps = ["ADTypes", "Accessors", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "FastBroadcast", "FastClosures", "FastPower", "FillArrays", "FunctionWrappersWrappers", "InteractiveUtils", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleUnPack", "Static", "StaticArrayInterface", "StaticArraysCore", "SymbolicIndexingInterface", "TruncatedStacktraces"]
1336-
git-tree-sha1 = "d29adfeb720dd7c251b216d91c4bd4fe67c087df"
1336+
git-tree-sha1 = "08dac9c6672a4548439048089bac293759a897fd"
13371337
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
1338-
version = "1.26.0"
1338+
version = "1.26.1"
13391339
weakdeps = ["EnzymeCore"]
13401340

13411341
[deps.OrdinaryDiffEqCore.extensions]
@@ -1915,9 +1915,9 @@ version = "3.29.0"
19151915

19161916
[[deps.Symbolics]]
19171917
deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "LaTeXStrings", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "OffsetArrays", "PrecompileTools", "Primes", "RecipesBase", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"]
1918-
git-tree-sha1 = "e14834f421edaa8a30493f7864dfc8582855bb3c"
1918+
git-tree-sha1 = "3d9551301d9ecdb8c193aac2ed0a3efc303494ca"
19191919
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1920-
version = "6.40.0"
1920+
version = "6.41.0"
19211921

19221922
[deps.Symbolics.extensions]
19231923
SymbolicsForwardDiffExt = "ForwardDiff"
@@ -1990,9 +1990,9 @@ version = "1.0.0"
19901990

19911991
[[deps.ThreadingUtilities]]
19921992
deps = ["ManualMemory"]
1993-
git-tree-sha1 = "2d529b6b22791f3e22e7ec5c60b9016e78f5f6bf"
1993+
git-tree-sha1 = "d969183d3d244b6c33796b5ed01ab97328f2db85"
19941994
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
1995-
version = "0.5.4"
1995+
version = "0.5.5"
19961996

19971997
[[deps.TimeZones]]
19981998
deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
@@ -2057,14 +2057,16 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
20572057

20582058
[[deps.Unitful]]
20592059
deps = ["Dates", "LinearAlgebra", "Random"]
2060-
git-tree-sha1 = "d62610ec45e4efeabf7032d67de2ffdea8344bed"
2060+
git-tree-sha1 = "d2282232f8a4d71f79e85dc4dd45e5b12a6297fb"
20612061
uuid = "1986cc42-f94f-5a68-af5c-568840ba703d"
2062-
version = "1.22.1"
2063-
weakdeps = ["ConstructionBase", "InverseFunctions"]
2062+
version = "1.23.1"
2063+
weakdeps = ["ConstructionBase", "ForwardDiff", "InverseFunctions", "Printf"]
20642064

20652065
[deps.Unitful.extensions]
20662066
ConstructionBaseUnitfulExt = "ConstructionBase"
2067+
ForwardDiffExt = "ForwardDiff"
20672068
InverseFunctionsUnitfulExt = "InverseFunctions"
2069+
PrintfExt = "Printf"
20682070

20692071
[[deps.Unityper]]
20702072
deps = ["ConstructionBase"]

Manifest-v1.11.toml.default

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
146146
version = "1.11.0"
147147

148148
[[deps.Bijections]]
149-
git-tree-sha1 = "6aaafea90a56dc1fc8cbc15e3cf26d6bc81eb0a3"
149+
git-tree-sha1 = "a2d308fcd4c2fb90e943cf9cd2fbfa9c32b69733"
150150
uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04"
151-
version = "0.1.10"
151+
version = "0.2.2"
152152

153153
[[deps.BitIntegers]]
154154
deps = ["Random"]
@@ -1003,9 +1003,9 @@ weakdeps = ["LineSearches"]
10031003

10041004
[[deps.LineSearches]]
10051005
deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"]
1006-
git-tree-sha1 = "e4c3be53733db1051cc15ecf573b1042b3a712a1"
1006+
git-tree-sha1 = "4adee99b7262ad2a1a4bbbc59d993d24e55ea96f"
10071007
uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
1008-
version = "7.3.0"
1008+
version = "7.4.0"
10091009

10101010
[[deps.LinearAlgebra]]
10111011
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
@@ -1946,9 +1946,9 @@ version = "3.29.0"
19461946

19471947
[[deps.Symbolics]]
19481948
deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "LaTeXStrings", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "OffsetArrays", "PrecompileTools", "Primes", "RecipesBase", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"]
1949-
git-tree-sha1 = "e14834f421edaa8a30493f7864dfc8582855bb3c"
1949+
git-tree-sha1 = "3d9551301d9ecdb8c193aac2ed0a3efc303494ca"
19501950
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1951-
version = "6.40.0"
1951+
version = "6.41.0"
19521952

19531953
[deps.Symbolics.extensions]
19541954
SymbolicsForwardDiffExt = "ForwardDiff"
@@ -2022,9 +2022,9 @@ version = "1.0.0"
20222022

20232023
[[deps.ThreadingUtilities]]
20242024
deps = ["ManualMemory"]
2025-
git-tree-sha1 = "2d529b6b22791f3e22e7ec5c60b9016e78f5f6bf"
2025+
git-tree-sha1 = "d969183d3d244b6c33796b5ed01ab97328f2db85"
20262026
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
2027-
version = "0.5.4"
2027+
version = "0.5.5"
20282028

20292029
[[deps.TimeZones]]
20302030
deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
1.14 MB
Binary file not shown.
1.14 MB
Binary file not shown.

examples/lin_ram_model.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ end
2727

2828
using KiteModels, LinearAlgebra, Statistics, OrdinaryDiffEqCore
2929
using ModelingToolkit
30-
using ModelingToolkit: t_nounits as t
30+
using ModelingToolkit: t_nounits
3131
toc()
3232

3333
# TODO: use sparse autodiff
@@ -56,7 +56,7 @@ s.set.rel_tol = 1e-2
5656
toc()
5757

5858
# Define outputs for linearization - heading
59-
lin_outputs = @variables heading(t)[1]
59+
lin_outputs = @variables heading(t_nounits)[1]
6060

6161
# Initialize at elevation with linearization outputs
6262
s.system_structure.winches[2].tether_length += 0.2

examples/ram_air_kite.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set_values = [-50, 0.0, 0.0] # Set values of the torques of the three winches.
3636
set.quasi_static = false
3737
set.physical_model = SIMPLE ? "simple_ram" : "ram"
3838

39-
@info "Creating wing, aero, vsm_solver, system_structure and s:"
39+
@info "Creating wing, aero, vsm_solver, system_structure and symbolic_awe_model:"
4040
sam = SymbolicAWEModel(set)
4141
sam.set.abs_tol = 1e-2
4242
sam.set.rel_tol = 1e-2
@@ -82,7 +82,9 @@ try
8282
end
8383

8484
# Step simulation
85-
steptime = @elapsed (t_new, integ_steptime) = next_step!(sam; set_values, dt, vsm_interval=vsm_interval)
85+
steptime = @elapsed next_step!(sam; set_values, dt, vsm_interval=vsm_interval)
86+
t_new = sam.integrator.t
87+
integ_steptime = sam.t_step
8688
t = t_new - t0 # Adjust for initial stabilization time
8789

8890
# Track performance after initial transient

src/KiteModels.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ Parameters:
630630
- dt: time step in seconds
631631
632632
Returns:
633-
The end time of the time step in seconds.
633+
`Nothing`
634634
"""
635635
function next_step!(s::AKM, integrator; set_speed = nothing, set_torque=nothing, set_force=nothing, bearing = nothing,
636636
attractor=nothing, v_wind_gnd=s.set.v_wind, upwind_dir=-pi/2, dt=1/s.set.sample_freq)
@@ -662,7 +662,7 @@ function next_step!(s::AKM, integrator; set_speed = nothing, set_torque=nothing,
662662
s.pitch_rate = (pitch - s.pitch) / dt
663663
s.pitch = pitch
664664
end
665-
integrator.t
665+
return nothing
666666
end
667667

668668
"""

src/ram_air_kite.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ $(TYPEDFIELDS)
7171

7272
prob::Union{OrdinaryDiffEqCore.ODEProblem, Nothing} = nothing
7373
integrator::Union{OrdinaryDiffEqCore.ODEIntegrator, Nothing} = nothing
74+
t_vsm::S = zero(S)
75+
t_step::S = zero(S)
7476
end
7577

7678
function SymbolicAWEModel(
@@ -511,7 +513,7 @@ This function performs the following steps:
511513
- `vsm_interval=1`: Interval (in number of steps) at which to linearize the VSM model. If 0, the VSM model is not linearized.
512514
513515
# Returns
514-
- `Tuple{SimFloat, Float64}`: A tuple containing the current simulation time and the time taken for the step.
516+
- `Nothing`
515517
"""
516518
function next_step!(s::SymbolicAWEModel, integrator::OrdinaryDiffEqCore.ODEIntegrator; set_values=nothing, upwind_dir=nothing, dt=1/s.set.sample_freq, vsm_interval=1)
517519
!(s.integrator === integrator) && error("The ODEIntegrator doesn't belong to the SymbolicAWEModel")
@@ -526,17 +528,17 @@ function next_step!(s::SymbolicAWEModel; set_values=nothing, upwind_dir=nothing,
526528
s.set_wind_dir(s.integrator, upwind_dir)
527529
end
528530
if vsm_interval != 0 && s.iter % vsm_interval == 0
529-
linearize_vsm!(s)
531+
s.t_vsm = @elapsed linearize_vsm!(s)
530532
end
531533

532534
s.t_0 = s.integrator.t
533-
steptime = @elapsed OrdinaryDiffEqCore.step!(s.integrator, dt, true)
535+
s.t_step = @elapsed OrdinaryDiffEqCore.step!(s.integrator, dt, true)
534536
if !successful_retcode(s.integrator.sol)
535537
println("Return code for solution: ", s.integrator.sol.retcode)
536538
end
537539
@assert successful_retcode(s.integrator.sol)
538540
s.iter += 1
539-
s.integrator.t, steptime
541+
return nothing
540542
end
541543

542544
function get_prob_name(set::Settings; precompile=false)

test/test_for_precompile.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ if ! haskey(ENV, "NO_MTK")
110110
set = se("system_ram.yaml")
111111
set.segments = 2
112112
set_values = [-50, -1.1, -1.1]
113-
mtk_kite = SymbolicAWEModel(set)
114-
KiteModels.init_sim!(mtk_kite)
115-
logger = Logger(length(mtk_kite.system_structure.points), 5)
113+
sam = SymbolicAWEModel(set)
114+
KiteModels.init_sim!(sam)
115+
logger = Logger(length(sam.system_structure.points), 5)
116116

117117
for i in 1:5
118-
next_step!(mtk_kite, set_values)
119-
sys_state = KiteModels.SysState(mtk_kite)
118+
next_step!(sam; set_values)
119+
sys_state = KiteModels.SysState(sam)
120120
log!(logger, sys_state)
121121
end
122122
end

test/test_ram_air_kite.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,15 @@ const BUILD_SYS = true
155155
# Run a simulation step with zero set values
156156
set_values = [0.0, 0.0, 0.0]
157157
dt = 1/s.set.sample_freq
158-
t, _ = next_step!(s; set_values, dt=dt)
158+
next_step!(s; set_values, dt=dt)
159159
# Update sys_state_before *after* the step to compare with the state *before* the loop
160160
KiteModels.update_sys_state!(sys_state_before, s)
161-
@test isapprox(t, dt, atol=TOL)
161+
@test isapprox(s.integrator.t, dt, atol=TOL)
162162

163163
# Run multiple steps
164164
num_steps = 10
165-
total_time = 0.0
166165
for _ in 1:num_steps
167-
step_time, _ = next_step!(s; set_values, dt=dt)
168-
total_time += step_time # Accumulate time from next_step! return value
166+
next_step!(s; set_values, dt=dt)
169167
end
170168
sys_state_after = KiteModels.SysState(s) # Get state after the loop
171169
# Compare state after loop with state after first step (stored in sys_state_before)

0 commit comments

Comments
 (0)