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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ StatsBase = "0.34"
SteadyStateDiffEq = "2.5"
Suppressor = "0.2.8"
SymbolicIndexingInterface = "0.3"
SymbolicUtils = "3.25"
SymbolicUtils = "~3.29"
TOML = "1.0.3"
Tar = "1.10.0"
Test = "1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
SPDX-FileCopyrightText: 2025 Uwe Fechner, Bart van de Lint
SPDX-License-Identifier: MIT
SPDX-License-Identifier: MPL-2.0
-->

# SymbolicAWEModels
Expand Down
6 changes: 5 additions & 1 deletion docs/src/private_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ SymbolicAWEModels.linear_vsm_eqs!
SymbolicAWEModels.force_eqs!
SymbolicAWEModels.linearize_vsm!
SymbolicAWEModels.jacobian
SymbolicAWEModels.generate_getters
SymbolicAWEModels.load_serialized_model!
SymbolicAWEModels.generate_getters!
SymbolicAWEModels.maybe_create_lin_prob!
SymbolicAWEModels.maybe_create_control_functions!
SymbolicAWEModels.maybe_create_prob!
```

## Utility and Internal Functions
Expand Down
11 changes: 1 addition & 10 deletions examples/ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ steering_magnitude = 10.0 # Magnitude of steering input [Nm]

# Initialize model
set = Settings("system.yaml")

@info "Creating SymbolicAWEModel:"
sam = SymbolicAWEModel(set)
toc()
SymbolicAWEModels.init!(sam)
@info "System initialized at:"
toc()

find_steady_state!(sam)
bias = 0.15
Expand All @@ -40,8 +35,4 @@ if set.physical_model == "4_attach_ram"
end
sl, _ = sim_oscillate!(sam; dt, total_time, vsm_interval, steering_freq, steering_magnitude,
bias, prn=true)
@info "Simulated at:"
toc()
display(plot(sam.sys_struct, sl))
@info "Plotted at:"
toc()
nothing
2 changes: 1 addition & 1 deletion examples/simple_tuned_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ init!(tether_sam)

simple_set = Settings("system.yaml")
simple_sam = SymbolicAWEModel(simple_set, "simple_ram")
init!(simple_sam)
init!(simple_sam; create_control_func=true)

sim_oscillate!(sam; total_time=1.0)
SymbolicAWEModels.copy_to_simple!(sam, tether_sam, simple_sam)
Expand Down
1 change: 1 addition & 0 deletions src/SymbolicAWEModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using ControlSystemsBase
using RecipesBase
using StaticArrays
using SymbolicIndexingInterface
using SymbolicIndexingInterface: AbstractIndexer

# --- Solvers (Nonlinear, Differential Equations) ---
using NonlinearSolve
Expand Down
3 changes: 1 addition & 2 deletions src/generate_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ function force_eqs!(s, system, psys, pset, eqs, defaults, guesses;
F .+= 0.5drag_force[:, segment.idx]
end
end
@assert !iszero(mass)

eqs = [
eqs
Expand Down Expand Up @@ -362,7 +361,7 @@ function force_eqs!(s, system, psys, pset, eqs, defaults, guesses;
acc[:, point.idx] ⋅ axis * axis,
acc[:, point.idx]
)
acc[:, point.idx] ~ point_force[:, point.idx] / mass - bridle_damp_vec
acc[:, point.idx] ~ point_force[:, point.idx] ./ mass - bridle_damp_vec
]
defaults = [
defaults
Expand Down
26 changes: 13 additions & 13 deletions src/linearize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ velocity, twist angles), linearizes the VSM aerodynamics around this operating p
and updates the Jacobian (`vsm_jac`) and the steady-state forces (`vsm_x`) in the
`SystemStructure`. This is typically called periodically during a simulation.
"""
function linearize_vsm!(s::SymbolicAWEModel, integ=s.integrator)
wings = s.sys_struct.wings
function linearize_vsm!(sam::SymbolicAWEModel, integ=sam.integrator)
wings = sam.sys_struct.wings
if length(wings) > 0
vsm_y = s.get_vsm_y(integ)
vsm_y = sam.get_vsm_y(integ)
for wing in wings
wing.vsm_y .= vsm_y[wing.idx,:]
res = VortexStepMethod.linearize(
Expand All @@ -57,13 +57,13 @@ function linearize_vsm!(s::SymbolicAWEModel, integ=s.integrator)
wing.vsm_y;
va_idxs=1:3,
omega_idxs=4:6,
theta_idxs=7:6+length(s.sys_struct.groups),
moment_frac=s.sys_struct.groups[1].moment_frac
theta_idxs=7:6+length(sam.sys_struct.groups),
moment_frac=sam.sys_struct.groups[1].moment_frac
)
wing.vsm_jac .= res[1]
wing.vsm_x .= res[2]
end
s.set_psys(integ, s.sys_struct)
sam.set_sys(integ, sam.sys_struct)
end
nothing
end
Expand All @@ -85,13 +85,13 @@ calculate the A, B, C, and D matrices for the complete, high-order system.
# Returns
- `LinType`: A NamedTuple `(A, B, C, D)` containing the state-space matrices.
"""
function linearize!(s::SymbolicAWEModel; set_values=s.get_set_values(s.integrator))
isnothing(s.lin_prob) && error("Run init! with remake=true and lin_outputs=...")
s.set_lin_set_values(s.lin_prob, set_values)
s.set_psys(s.lin_prob, s.sys_struct)
s.set_set(s.lin_prob, s.set)
s.lin_model = solve(s.lin_prob)[1]
return s.lin_model
function linearize!(sam::SymbolicAWEModel; set_values=sam.get_set_values(sam.integrator))
isnothing(sam.lin_prob) && error("Run init! with remake=true and lin_outputs=...")
sam.set_lin_set_values(sam.lin_prob, set_values)
sam.set_lin_sys(sam.lin_prob, sam.sys_struct)
sam.set_lin_set(sam.lin_prob, sam.set)
sam.lin_model = solve(sam.lin_prob)[1]
return sam.lin_model
end

"""
Expand Down
4 changes: 2 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2024 Uwe Fechner, Bart van de Lint
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Uwe Fechner, Bart van de Lint
# SPDX-License-Identifier: MPL-2.0

"""
create_model_archive(source_dir, archive_path)
Expand Down
4 changes: 3 additions & 1 deletion src/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ function sim_oscillate!(
set_values = zeros(Float64, steps, num_winches)

if prn
@info "Generating oscillating steering commands..."
@info "Simulating using oscillating steering inputs\n" *
"\twith frequency = $steering_freq Hz\n" *
"\tand magnitude = $steering_magnitude N."
end

for step in 1:steps
Expand Down
Loading
Loading