diff --git a/docs/src/index.md b/docs/src/index.md index c07c3367e..19ab607e0 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -83,7 +83,7 @@ times faster. - the documentation was improved ## Provides -The type [`AbstractKiteModel`](@ref) with the implementation [`KPS3`](@ref), [`KPS4`](@ref) and [`SymbolicAWEModel`](@ref), representing the one point, the four point kite model and the ram air kite model, together with the high level simulation interface consisting of the functions [`init_sim!`](@ref) and [`next_step!`](@ref). Other kite models can be added inside or outside of this package by implementing the non-generic methods required for an AbstractKiteModel. +The types [`KPS3`](@ref), [`KPS4`](@ref) and [`SymbolicAWEModel`](@ref), representing the one point, the four point kite model and the ram air kite model, together with the high level simulation interface consisting of the functions [`init_sim!`](@ref) and [`next_step!`](@ref). Other kite models can be added inside or outside of this package by implementing the non-generic methods required for an AbstractKiteModel. Additional functions to provide inputs and outputs of the model on each time step. In particular the constructor [`SysState`](@ref) can be called once per time step to create a SysState struct for logging or for displaying the state in a viewer. For the KPS3 and KPS4 model, once per time step the [`residual!`](@ref) function is called as many times as needed to find the solution at the end diff --git a/docs/src/types.md b/docs/src/types.md index 2cfa94078..faffcc9e6 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -9,7 +9,6 @@ CurrentModule = KiteModels SimFloat KVec3 SVec3 -AbstractKiteModel AKM ``` diff --git a/src/KPS3.jl b/src/KPS3.jl index 63d3c5fdb..4abe7c941 100644 --- a/src/KPS3.jl +++ b/src/KPS3.jl @@ -35,6 +35,8 @@ $(TYPEDFIELDS) am::AtmosphericModel = AtmosphericModel() "Reference to winch model as implemented in the package WinchModels" wm::Union{AbstractWinchModel, Nothing} = nothing + "Integrator, storing the current state" + integrator::Union{OrdinaryDiffEqCore.ODEIntegrator, Nothing} = nothing "Iterations, number of calls to the function residual!" iter:: Int64 = 0 "Function for calculation the lift coefficent, using a spline based on the provided value pairs." @@ -188,6 +190,10 @@ function KPS3(kcu::KCU) clear!(s) return s end +function KPS3(set::Settings) + kcu = KCU(set) + KPS3(kcu) +end """ calc_drag(s::KPS3, v_segment, unit_vector, rho, last_tether_drag, v_app_perp) diff --git a/src/KPS4.jl b/src/KPS4.jl index c5dee9c65..88df56033 100644 --- a/src/KPS4.jl +++ b/src/KPS4.jl @@ -68,6 +68,8 @@ $(TYPEDFIELDS) am::AtmosphericModel = AtmosphericModel() "Reference to winch model as implemented in the package WinchModels" wm::AbstractWinchModel + "Integrator, storing the current state" + integrator::Union{OrdinaryDiffEqCore.ODEIntegrator, Nothing} = nothing "Iterations, number of calls to the function residual!" iter:: Int64 = 0 "Function for calculation the lift coefficient, using a spline based on the provided value pairs." @@ -233,6 +235,10 @@ function KPS4(kcu::KCU) clear!(s) return s end +function KPS4(set::Settings) + kcu = KCU(set) + KPS4(kcu) +end """ calc_particle_forces!(s::KPS4, pos1, pos2, vel1, vel2, spring, segments, d_tether, rho, i) diff --git a/src/KiteModels.jl b/src/KiteModels.jl index 92fb29d3a..b3f2a4528 100644 --- a/src/KiteModels.jl +++ b/src/KiteModels.jl @@ -81,14 +81,6 @@ Basic 3-dimensional vector, stack allocated, immutable. """ const SVec3 = SVector{3, SimFloat} -""" - abstract type AbstractKiteModel - -All kite models must inherit from this type. All methods that are defined on this type must work -with all kite models. All exported methods must work on this type. -""" -abstract type AbstractKiteModel end - """ const AKM = AbstractKiteModel diff --git a/test/runtests.jl b/test/runtests.jl index cdc5e5721..92ef7faf6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -37,5 +37,7 @@ KiteUtils.set_data_path("") println("--> 4") include("test_inertia_calculation.jl") println("--> 5") + include("test_interface.jl") + println("--> 6") include("aqua.jl") end \ No newline at end of file diff --git a/test/test_interface.jl b/test/test_interface.jl new file mode 100644 index 000000000..32c6fe83d --- /dev/null +++ b/test/test_interface.jl @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2025 Uwe Fechner +# SPDX-License-Identifier: MIT + +using KiteModels, KiteUtils, Test + +set = load_settings("system.yaml") +kps3::KPS3 = KPS3(set) +kps4::KPS4 = KPS4(set) +set = load_settings("system_ram.yaml") +sam::SymbolicAWEModel = SymbolicAWEModel(set) + +@testset "KPS3 constructor interface" begin + @test kps3 isa KiteUtils.AbstractKiteModel + @test kps3.set isa KiteUtils.Settings + @test isnothing(kps3.integrator) + @test kps3.am isa AtmosphericModel + @test kps3.iter isa Int64 +end +@testset "KPS4 constructor interface" begin + @test kps4 isa KiteUtils.AbstractKiteModel + @test kps4.set isa KiteUtils.Settings + @test isnothing(kps4.integrator) + @test kps4.am isa AtmosphericModel + @test kps4.iter isa Int64 +end +@testset "SymbolicAWEModel constructor interface" begin + @test sam isa KiteUtils.AbstractKiteModel + @test sam.set isa KiteUtils.Settings + @test isnothing(sam.integrator) + @test sam.am isa AtmosphericModel + @test sam.iter isa Int64 +end +nothing