Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 20 additions & 18 deletions Manifest-v1.10.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.9"
manifest_format = "2.0"
project_hash = "e060360f8cac442cf470fedd0c1378b00cf639db"
project_hash = "e5116e83aee3763e3ebd89b0de5522b585f68fec"

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

[[deps.Bijections]]
git-tree-sha1 = "6aaafea90a56dc1fc8cbc15e3cf26d6bc81eb0a3"
git-tree-sha1 = "a2d308fcd4c2fb90e943cf9cd2fbfa9c32b69733"
uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04"
version = "0.1.10"
version = "0.2.2"

[[deps.BitIntegers]]
deps = ["Random"]
Expand Down Expand Up @@ -328,9 +328,9 @@ uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.5.0"

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

[deps.ConstructionBase.extensions]
Expand Down Expand Up @@ -889,9 +889,9 @@ version = "0.3.8"

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

[[deps.Krylov]]
deps = ["LinearAlgebra", "Printf", "SparseArrays"]
Expand Down Expand Up @@ -995,9 +995,9 @@ weakdeps = ["LineSearches"]

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

[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
Expand Down Expand Up @@ -1333,9 +1333,9 @@ version = "1.6.0"

[[deps.OrdinaryDiffEqCore]]
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"]
git-tree-sha1 = "d29adfeb720dd7c251b216d91c4bd4fe67c087df"
git-tree-sha1 = "08dac9c6672a4548439048089bac293759a897fd"
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
version = "1.26.0"
version = "1.26.1"
weakdeps = ["EnzymeCore"]

[deps.OrdinaryDiffEqCore.extensions]
Expand Down Expand Up @@ -1915,9 +1915,9 @@ version = "3.29.0"

[[deps.Symbolics]]
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"]
git-tree-sha1 = "e14834f421edaa8a30493f7864dfc8582855bb3c"
git-tree-sha1 = "3d9551301d9ecdb8c193aac2ed0a3efc303494ca"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
version = "6.40.0"
version = "6.41.0"

[deps.Symbolics.extensions]
SymbolicsForwardDiffExt = "ForwardDiff"
Expand Down Expand Up @@ -1990,9 +1990,9 @@ version = "1.0.0"

[[deps.ThreadingUtilities]]
deps = ["ManualMemory"]
git-tree-sha1 = "2d529b6b22791f3e22e7ec5c60b9016e78f5f6bf"
git-tree-sha1 = "d969183d3d244b6c33796b5ed01ab97328f2db85"
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
version = "0.5.4"
version = "0.5.5"

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

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

[deps.Unitful.extensions]
ConstructionBaseUnitfulExt = "ConstructionBase"
ForwardDiffExt = "ForwardDiff"
InverseFunctionsUnitfulExt = "InverseFunctions"
PrintfExt = "Printf"

[[deps.Unityper]]
deps = ["ConstructionBase"]
Expand Down
16 changes: 8 additions & 8 deletions Manifest-v1.11.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
version = "1.11.0"

[[deps.Bijections]]
git-tree-sha1 = "6aaafea90a56dc1fc8cbc15e3cf26d6bc81eb0a3"
git-tree-sha1 = "a2d308fcd4c2fb90e943cf9cd2fbfa9c32b69733"
uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04"
version = "0.1.10"
version = "0.2.2"

[[deps.BitIntegers]]
deps = ["Random"]
Expand Down Expand Up @@ -1003,9 +1003,9 @@ weakdeps = ["LineSearches"]

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

[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
Expand Down Expand Up @@ -1946,9 +1946,9 @@ version = "3.29.0"

[[deps.Symbolics]]
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"]
git-tree-sha1 = "e14834f421edaa8a30493f7864dfc8582855bb3c"
git-tree-sha1 = "3d9551301d9ecdb8c193aac2ed0a3efc303494ca"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
version = "6.40.0"
version = "6.41.0"

[deps.Symbolics.extensions]
SymbolicsForwardDiffExt = "ForwardDiff"
Expand Down Expand Up @@ -2022,9 +2022,9 @@ version = "1.0.0"

[[deps.ThreadingUtilities]]
deps = ["ManualMemory"]
git-tree-sha1 = "2d529b6b22791f3e22e7ec5c60b9016e78f5f6bf"
git-tree-sha1 = "d969183d3d244b6c33796b5ed01ab97328f2db85"
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
version = "0.5.4"
version = "0.5.5"

[[deps.TimeZones]]
deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
Expand Down
Binary file added data/prob_1.10_ram_dynamic_3_seg.bin.default.xz
Binary file not shown.
Binary file added data/prob_1.11_ram_dynamic_3_seg.bin.default.xz
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/lin_ram_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end

using KiteModels, LinearAlgebra, Statistics, OrdinaryDiffEqCore
using ModelingToolkit
using ModelingToolkit: t_nounits as t
using ModelingToolkit: t_nounits
toc()

# TODO: use sparse autodiff
Expand Down Expand Up @@ -56,7 +56,7 @@ s.set.rel_tol = 1e-2
toc()

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

# Initialize at elevation with linearization outputs
s.system_structure.winches[2].tether_length += 0.2
Expand Down
6 changes: 4 additions & 2 deletions examples/ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set_values = [-50, 0.0, 0.0] # Set values of the torques of the three winches.
set.quasi_static = false
set.physical_model = SIMPLE ? "simple_ram" : "ram"

@info "Creating wing, aero, vsm_solver, system_structure and s:"
@info "Creating wing, aero, vsm_solver, system_structure and symbolic_awe_model:"
sam = SymbolicAWEModel(set)
sam.set.abs_tol = 1e-2
sam.set.rel_tol = 1e-2
Expand Down Expand Up @@ -82,7 +82,9 @@ try
end

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

# Track performance after initial transient
Expand Down
4 changes: 2 additions & 2 deletions src/KiteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ Parameters:
- dt: time step in seconds

Returns:
The end time of the time step in seconds.
`Nothing`
"""
function next_step!(s::AKM, integrator; set_speed = nothing, set_torque=nothing, set_force=nothing, bearing = nothing,
attractor=nothing, v_wind_gnd=s.set.v_wind, upwind_dir=-pi/2, dt=1/s.set.sample_freq)
Expand Down Expand Up @@ -662,7 +662,7 @@ function next_step!(s::AKM, integrator; set_speed = nothing, set_torque=nothing,
s.pitch_rate = (pitch - s.pitch) / dt
s.pitch = pitch
end
integrator.t
return nothing
end

"""
Expand Down
10 changes: 6 additions & 4 deletions src/ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ $(TYPEDFIELDS)

prob::Union{OrdinaryDiffEqCore.ODEProblem, Nothing} = nothing
integrator::Union{OrdinaryDiffEqCore.ODEIntegrator, Nothing} = nothing
t_vsm::S = zero(S)
t_step::S = zero(S)
end

function SymbolicAWEModel(
Expand Down Expand Up @@ -511,7 +513,7 @@ This function performs the following steps:
- `vsm_interval=1`: Interval (in number of steps) at which to linearize the VSM model. If 0, the VSM model is not linearized.

# Returns
- `Tuple{SimFloat, Float64}`: A tuple containing the current simulation time and the time taken for the step.
- `Nothing`
"""
function next_step!(s::SymbolicAWEModel, integrator::OrdinaryDiffEqCore.ODEIntegrator; set_values=nothing, upwind_dir=nothing, dt=1/s.set.sample_freq, vsm_interval=1)
!(s.integrator === integrator) && error("The ODEIntegrator doesn't belong to the SymbolicAWEModel")
Expand All @@ -526,17 +528,17 @@ function next_step!(s::SymbolicAWEModel; set_values=nothing, upwind_dir=nothing,
s.set_wind_dir(s.integrator, upwind_dir)
end
if vsm_interval != 0 && s.iter % vsm_interval == 0
linearize_vsm!(s)
s.t_vsm = @elapsed linearize_vsm!(s)
end

s.t_0 = s.integrator.t
steptime = @elapsed OrdinaryDiffEqCore.step!(s.integrator, dt, true)
s.t_step = @elapsed OrdinaryDiffEqCore.step!(s.integrator, dt, true)
if !successful_retcode(s.integrator.sol)
println("Return code for solution: ", s.integrator.sol.retcode)
end
@assert successful_retcode(s.integrator.sol)
s.iter += 1
s.integrator.t, steptime
return nothing
end

function get_prob_name(set::Settings; precompile=false)
Expand Down
10 changes: 5 additions & 5 deletions test/test_for_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ if ! haskey(ENV, "NO_MTK")
set = se("system_ram.yaml")
set.segments = 2
set_values = [-50, -1.1, -1.1]
mtk_kite = SymbolicAWEModel(set)
KiteModels.init_sim!(mtk_kite)
logger = Logger(length(mtk_kite.system_structure.points), 5)
sam = SymbolicAWEModel(set)
KiteModels.init_sim!(sam)
logger = Logger(length(sam.system_structure.points), 5)

for i in 1:5
next_step!(mtk_kite, set_values)
sys_state = KiteModels.SysState(mtk_kite)
next_step!(sam; set_values)
sys_state = KiteModels.SysState(sam)
log!(logger, sys_state)
end
end
Expand Down
8 changes: 3 additions & 5 deletions test/test_ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,15 @@ const BUILD_SYS = true
# Run a simulation step with zero set values
set_values = [0.0, 0.0, 0.0]
dt = 1/s.set.sample_freq
t, _ = next_step!(s; set_values, dt=dt)
next_step!(s; set_values, dt=dt)
# Update sys_state_before *after* the step to compare with the state *before* the loop
KiteModels.update_sys_state!(sys_state_before, s)
@test isapprox(t, dt, atol=TOL)
@test isapprox(s.integrator.t, dt, atol=TOL)

# Run multiple steps
num_steps = 10
total_time = 0.0
for _ in 1:num_steps
step_time, _ = next_step!(s; set_values, dt=dt)
total_time += step_time # Accumulate time from next_step! return value
next_step!(s; set_values, dt=dt)
end
sys_state_after = KiteModels.SysState(s) # Get state after the loop
# Compare state after loop with state after first step (stored in sys_state_before)
Expand Down
Loading