Introduction
Most of the functions work on a KPS3 or KPS4 object. For this, the variable s is used. Such a variable can be created with the lines:
using KiteModels
set = load_settings("system.yaml")
s = KPS3(KCU(set))Or, if you want to use the 4 point kite model:
using KiteModels
set = load_settings("system.yaml")
s = KPS4(KCU(set))Functions with an "!" as last character of the function name modify one of more of their parameters, in this context mostly the variable s.
Input functions
KiteModels.set_depower_steering! — Function
set_depower_steering!(s::AKM, depower, steering)Setter for the depower and steering model inputs.
Parameters:
- depower: Relative depower, must be between 0 .. 1.0
- steering: Relative steering, must be between -1.0 .. 1.0.
This function sets the variables s.depower, s.steering and s.alpha_depower.
It takes the depower offset c0 and the dependency of the steering sensitivity from the depower settings into account. The raw steering value is stored in s.kcu_steering.
KiteModels.set_v_wind_ground! — Function
set_v_wind_ground!(s::AKM, height, v_wind_gnd=s.set.v_wind; upwind_dir=-pi/2, interpolate=false)Set the vector of the wind-velocity at the height of the kite. As parameter the height, the ground wind speed [m/s] and the upwind direction [radians] are needed. Is called by the function next_step!.
Both the mean and the turbulent wind come from calc_turbulent_wind, evaluated at the horizontal position of the kite and at height; interpolate is passed on to it. Since that function reads the ground wind speed from the settings, a v_wind_gnd differing from s.set.v_wind rescales the result; it has no effect while turbulence is switched on, where the wind field itself sets the speed.
s.v_wind_vert (set via the v_wind_vert keyword of next_step!, default 0.0) is added to the vertical component of s.v_wind after it is computed, on top of any vertical turbulence already present — it is a mean updraft/downdraft superimposed on the wind model, not a replacement for it. Positive is up. s.v_wind_gnd and s.v_wind_tether are unaffected: the tether wind stays horizontal, and upwind_dir (which reads s.v_wind_gnd) is unaffected too.
KiteModels.calc_turbulent_wind — Function
calc_turbulent_wind(am, pos, upwind_dir, t; interpolate=false)Calculate the wind velocity vectors at the kite and at the mid-tether point.
When am.set.use_turbulence == 0.0, returns the mean wind based on a log/power-law height profile. When use_turbulence != 0.0, returns the fully turbulent wind vectors looked up from the pre-computed wind field via get_wind.
Forwards to AtmosphericModels.calc_turbulent_wind, which takes upwind_dir as a keyword argument; the positional argument order used here is kept for backwards compatibility.
Parameters:
am: atmospheric model (settings are read fromam.set)pos: 3D position of the kite [m];pos[3]is used as height (clamped to 6 m minimum)upwind_dir: upwind direction in radians; zero is north, clockwise positivet: current simulation time [s]interpolate: iftrue, interpolate the turbulence trilinearly between the surrounding grid points instead of using the nearest one
Returns a tuple (v_wind, v_wind_tether) where:
v_wind: wind velocity vector at kite height [m/s]v_wind_tether: wind velocity vector at half the kite height [m/s]
KiteModels.get_default_turbulence — Function
get_default_turbulence() -> Union{Float64, Nothing}Read the configured default_turbulence from data/gui.yaml. If the file does not exist it is created from gui.yaml.default.
KiteModels.set_default_turbulence — Function
set_default_turbulence([value])Read or prompt for the default_turbulence setting in data/gui.yaml and persist the new value. If gui.yaml does not exist, it is created from gui.yaml.default.
Output functions
KiteModels.unstretched_length — Function
unstretched_length(s::AKM)Getter for the unstretched tether reel-out length (at zero force).
KiteModels.tether_length — Function
tether_length(s::AKM)Calculate and return the real, stretched tether length.
KiteModels.pos_kite — Function
pos_kite(s::KPS4)Return the position of the kite (top particle).
pos_kite(s::KPS3)Return the position of the kite (top particle).
KiteModels.calc_height — Function
calc_height(s::KPS4)Determine the height of the topmost kite particle above ground.
calc_height(s::KPS3)Determine the height of the kite particle above ground.
KiteUtils.calc_elevation — Function
calc_elevation(s::AKM)Determine the elevation angle of the kite in radian.
KiteModels.calc_azimuth — Function
calc_azimuth(s::AKM)Determine the azimuth angle of the kite in wind reference frame in radian. Positive anti-clockwise when seen from above.
KiteModels.calc_azimuth_east — Function
calc_azimuth_east(s::AKM)Determine the azimuth_east angle of the kite in radian. Positive clockwise when seen from above.
KiteModels.calc_azimuth_north — Function
calc_azimuth_north(s::AKM)Determine the azimuth_north angle of the kite in radian. Positive anti-clockwise when seen from above.
KiteUtils.calc_heading — Function
calc_heading(s::AKM; upwind_dir_=upwind_dir(s), neg_azimuth=false, one_point=false, respos=true)Determine the heading angle of the kite in radian.
KiteUtils.calc_course — Function
calc_course(s::AKM)Determine the course angle of the kite in radian. Undefined if the velocity of the kite is near zero.
KiteModels.cl_cd — Function
cl_cd(s::KPS4)Calculate the lift and drag coefficients of the kite, based on the current angles of attack.
cl_cd(s::KPS3)Calculate the lift and drag coefficients of the kite, based on the current angles of attack.
KiteModels.reel_out_speed — Function
reel_out_speed(s::KPS4)Return the current reel-out speed of the winch in m/s.
reel_out_speed(s::KPS3)Return the current reel-out speed of the winch in m/s.
KiteModels.winch_force — Function
winch_force(s::KPS4)Return the absolute value of the force at the winch as calculated during the last timestep.
winch_force(s::KPS3)Return the absolute value of the force at the winch as calculated during the last timestep.
KiteModels.spring_forces — Function
spring_forces(s::KPS4; prn=true, damping=true)Return the scalar forces of all springs [N], positive for tension: first the tether segments, then the springs of the kite. They are the forces of the residual for the positions s.pos and velocities s.vel, including the damping force, unless damping=false. With prn=true, a warning is printed if a force exceeds the breaking force.
spring_forces(s::AKM; damping=true)Return an array of the scalar spring forces of all tether segments [N], positive for tension, and for KPS4 also of the springs of the kite. They are the forces of the residual for the current positions and velocities, including the damping force, unless damping=false.
KiteModels.n_springs — Function
n_springs(s::AKM)Number of springs of the model: the tether segments and, for KPS4, the springs of the kite.
KiteModels.lift_drag — Function
lift_drag(s::AKM)Return a tuple of the scalar lift and drag forces.
Example:
lift, drag = lift_drag(s)KiteModels.lift_over_drag — Function
lift_over_drag(s::AKM)Return the lift-over-drag ratio.
KiteModels.v_wind_kite — Function
v_wind_kite(s::AKM)Return the vector of the wind speed at the height of the kite.
KiteModels.kite_ref_frame — Function
kite_ref_frame(s::KPS4; one_point=false)Returns a tuple of the x, y, and z vectors of the kite reference frame.
kite_ref_frame(s::KPS3)Returns a tuple of the x, y, and z vectors of the kite reference frame.
KiteModels.orient_euler — Function
orient_euler(s::AKM)Calculate and return the orientation of the kite in euler angles (roll, pitch, yaw) as SVector.
KiteModels.calc_orient_quat — Function
calc_orient_quat(s::AKM; viewer=false, one_point=false)Orientation of the kite as a quaternion in the KS convention (against NED).
KiteModels.states — Function
states(s::KPS3)Return the number of states of the KPS3 model.
states(s::KPS4)Return the number of states of the KPS4 model.
KiteUtils.SysState — Type
SysState(s::AKM, zoom=1.0; with_springs=true)Constructor for creating a SysState object from a kite model (KPS3 or KPS4). The SysState object can be used either for logging or for displaying the system state in a viewer. Optionally the position arrays can be zoomed according to the requirements of the viewer.
The field spring_force holds the forces of all springs (see spring_forces), or is empty if with_springs is false. The free fields var_13 and var_14 hold the internal state of the winch, the rate limited set speed wm.last_set_speed and the state of the brake wm.brake (0 or 1), so that init! can continue a simulation from the SysState; they are NaN without a winch model. A Logger for this SysState must be created with the same number of segments: Logger(P, steps; segments=n_springs(s)), or Logger(P, steps) with with_springs=false.
Saving the system state
The system state of one time step can be saved as human-readable YAML file, for example to inspect it or to compare two simulations. To log a whole simulation, use a Logger from KiteUtils instead.
KiteModels.save_state — Function
save_state(filename, ss::SysState; meta_data=Dict(), exclude=KiteModels.UNUSED_FIELDS)Write the system state ss to the YAML file filename: the entries of the dictionary meta_data under the key meta_data, and the fields of ss under the key sys_state, except the fields in exclude, by default the fields that KPS3 and KPS4 do not use. For KPS3, pass exclude=KiteModels.UNUSED_FIELDS_KPS3 to also leave out side_slip, alpha3 and alpha4, which it does not have, and the aerodynamic moment aero_moment_KA_x/y/z, which is always zero. Scalars are written as numbers, vectors as YAML flow sequences, NaN and Inf as .nan and .inf, all other values as quoted strings. The keys of meta_data are written as strings, quoted unless they are plain identifiers.
Example:
ss = SysState(kps4)
save_state("output/sys_state.yaml", ss; meta_data=Dict("script" => "test_init_4p"))The file can be read back with load_state.
KiteModels.load_state — Function
load_state(filename)Read a system state from the YAML file filename that save_state wrote. Returns the tuple (sys_state, meta_data) of a new SysState and the Dict of the meta data.
The number of points and of springs of the SysState is taken from the length of the fields X and spring_force in the file. Fields that are not in the file, for example because they were excluded when saving, keep the default values of SysState: zero, except for the orientation, which is the unit quaternion.
Example:
sys_state, meta_data = load_state("output/sys_state_test_init_4p.yaml")High level simulation interface
KiteUtils.init! — Function
init!(s::AKM; prn=false, steady_state=true, trim=false,
initial_state=nothing) -> Union{OrdinaryDiffEqCore.ODEIntegrator, Sundials.IDAIntegrator, Nothing}Initializes the integrator of the model (KPS3 and KPS4 only).
Parameters:
- s: an instance of an abstract kite model
- prn: if set to true, print the detailed solver results
- steadystate: if
true(default), call `findsteady_state!to solve for an equilibrium before constructing the integrator. Iffalse, skip the steady-state solver and initialise directly from the current model parameters viaKiteModels.init; this is faster but produces a non-equilibrium starting point, which is useful when the caller has already set up a consistent state or when the steady-state solver is known to struggle (e.g. unusual wind conditions). Returnsnothing` if steady-state solving fails. - trim: if
true, the steady state is found at the natural elevation of the kite, where its lift matches gravity, instead of ats.set.elevation; seefind_steady_state!. If no trim with attached flow is found,nothingis returned. Ignored ifsteady_stateisfalse. - initialstate: a
SysStateto continue a simulation from, for example from [`loadstate](@ref). The model gets the positions and velocities of the particles, the tether length, the reel-out speed, the set values and the internal state of the winch and the depower and steering of the KCU from it, andsteadystateandtrimare ignored. The integrator continues atinitialstate.time, which must be the time of the state,integrator.twhen it was saved; aSysStatefromupdatesysstate!holds the start time of the last time step instead. For KPS4, the pitch rate of the kite is calculated from the velocities of the particles; it differs by O(dt) from the change of the pitch angle during the last time step, whichnext_step!` uses otherwise. The state of the controllers of the caller is not restored.
Without initial_state, the initial state is taken from the section initial of the settings; for KPS3 and KPS4 only the first value of each vector is used:
l_tethers,v_reel_outsanddepowers: the tether length, the reel-out speed and the depower setting.elevations: the elevation of the kite; withtrim=trueonly the start value of the search for the natural elevation.azimuths: the azimuth of the kite in the wind reference frame; seefind_steady_state!.steerings: the steering setting [%] of the KCU.headings(KPS4 only): the heading of the kite. After the steady state was found, the kite is turned about the line from the KCU to the kite, which keeps the position of the kite and the lengths of all springs; the tether is not changed. A kite with a heading other than zero is not in equilibrium: it flies towards its nose. The one-point kite of KPS3 has no heading of its own, so the heading is ignored.elevation_ratesandazimuth_rates: the tether and the kite rotate as a rigid body about the winch, so that the elevation and the azimuth of the kite change with these rates [°/s].heading_rates(KPS4 only): the kite also rotates about the line from the KCU to the kite, so that its heading changes with this rate [°/s]. The rates only set the velocities, not the accelerations, so the initial state is not consistent with them, which causes a transient during the first fraction of a second. For example, with an elevation rate of -5 °/s the tether force of KPS4 drops from 502 N to 48 N within 0.1 s. Without steering, the heading rate decays within about 0.1 s.kite_distancesis ignored.
The steady state is solved with the steering applied; its symmetric forces are balanced, but a steering other than zero makes the kite turn.
The keyword arguments delta and stiffness_factor are deprecated and ignored: with steady_state=true, the initial state is an equilibrium for the full tether stiffness.
Returns: An instance of an ODEIntegrator or IDAIntegrator, or nothing if initialization fails.
KiteUtils.next_step! — 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, v_wind_vert=0.0,
dt=1/s.set.sample_freq, interpolate=false)Calculates the next simulation step. Either set_speed or set_torque must be provided.
Parameters:
- s: an instance of an abstract kite model
- integrator: an integrator instance as returned by the function
init! - set_speed: set value of reel out speed in m/s or nothing
- set_torque: set value of the torque in Nm or nothing
- set_force: set value of the force in N or nothing (only for logging, not used otherwise)
- bearing: set value of heading/ course in radian or nothing (only for logging, not used otherwise)
- attractor: the attractor coordinates [azimuth, elevation] in radian or nothing (only for logging)
v_wind_gnd: wind speed at reference height in m/supwind_dir: upwind direction in radians, the direction the wind is coming from. Zero is at north; clockwise positive. Default: -pi/2, wind from west.v_wind_vert: constant vertical wind velocity at the kite, positive up [m/s]. Added on top of whatever the wind model (laminar or turbulent) already produces; does not affects.v_wind_gndor the tether wind. Default0.0, fully backward compatible.- dt: time step in seconds
interpolate: iftrue, interpolate the turbulence between the grid points of the wind field instead of using the nearest one. Removes the steps a kite flying through the field sees; without turbulence it makes no difference.
Returns: Nothing
Low level simulation interface
KiteModels.clear! — Function
clear!(s::KPS4)Initialize the kite power model.
clear!(s::KPS3)Initialize the kite power model.
KiteModels.find_steady_state! — Function
find_steady_state!(s::KPS4; prn=false, upwind_dir=-pi/2, trim=false)Find an initial equilibrium, based on the initial parameters l_tether, elevation, azimuth and v_reel_out.
The forces on the tether particles, the KCU and the kite particles are balanced (without gravity), except for the z component of the kite points C and D: instead, the elevation of the kite (pos_kite, point B) is kept at s.set.elevation, because the kite can only be fully balanced at its natural elevation. Therefore calc_elevation(s) returns s.set.elevation after the steady state was found. If the prescribed elevation is far below the natural elevation, the kite can only be balanced in deep stall, with an angle of attack beyond the angle of maximum lift; then a warning is logged.
The kite is placed at the azimuth s.set.azimuth (in degrees, in the wind reference frame). For an azimuth other than zero, the lateral forces on the tether particles are balanced too, but the lateral forces on the kite and the KCU are not: instead, the kite is kept at the prescribed azimuth. The kite is not in equilibrium there, it has a side slip angle, and without steering it swings back towards the azimuth zero.
If trim is true, all forces including gravity are balanced, also the z components of the forces on C and D, and the elevation is solved for instead: the kite is placed at the elevation where its lift matches gravity (its natural elevation), starting the search at 80° or at s.set.elevation, if it is higher: the solver converges from above the natural elevation, but often not from far below it. Trimmed steady states with an angle of attack beyond the angle of maximum lift (deep stall) are rejected. If no valid trim is found from the start elevation, the solver is restarted at higher and then at lower elevations than s.set.elevation, in steps of 10°. If this fails too, an error is thrown, and init! returns nothing.
The steady state is always solved for the full tether stiffness (s.stiffness_factor is 1.0 afterwards). The nonlinear solver is sensitive to the starting point, so small floating-point differences (e.g. between Julia versions) can decide whether it converges. If the first attempt fails, it is repeated without autoscaling and then by continuation: a solution is first found for a reduced tether stiffness and then used as start value for the full stiffness. The initial state is not perturbed, unless this fails; the returned steady state is never perturbed.
The keyword arguments delta and stiffness_factor are deprecated and ignored.
find_steady_state!(s::KPS3; prn=false, upwind_dir=-pi/2, trim=false)Find an initial equilibrium, based on the initial parameters l_tether, elevation, azimuth and v_reel_out.
The tether particles are in equilibrium. The kite is placed at the elevation angle from the settings, so only its horizontal force balance is solved for; the kite can only be fully balanced at its natural elevation. If the prescribed elevation is far below the natural elevation, the kite can only be balanced in deep stall, with an angle of attack beyond the angle of maximum lift; then a warning is logged.
The kite is placed at the azimuth s.set.azimuth (in degrees, in the wind reference frame). For an azimuth other than zero, the lateral forces on the tether particles are balanced too, but the lateral forces on the kite are not: instead, the kite is kept at the prescribed azimuth. The kite is not in equilibrium there. Without a controller, the one-point kite is laterally unstable and moves further away from the azimuth zero.
If trim is true, the vertical force balance of the kite is solved for too and the elevation is free: the kite is placed at the elevation where its lift matches gravity (its natural elevation), starting the search at s.set.elevation. Trimmed steady states with an angle of attack beyond the angle of maximum lift (deep stall) are rejected. If no valid trim is found from s.set.elevation, the solver is restarted at higher and then at lower elevations, in steps of 10°. If this fails too, an error is thrown, and init! returns nothing.
The steady state is always solved for the full tether stiffness; a solution for a reduced stiffness is only used as start value. The keyword arguments delta and stiffness_factor are deprecated and ignored.
KiteModels.residual! — Function
residual!(res, yd, y::MVector{S, SimFloat}, s::KPS4, time) where S
N-point tether model, four points for the kite on top:
Inputs:
State vector y = pos1, pos2, ... , posn, vel1, vel2, . .., veln, length, v_reel_out
Derivative yd = posd1, posd2, ..., posdn, veld1, veld2, ..., veldn, lengthd, v_reel_outd
Output:
Residual res = res1, res2 = vel1-posd1, ..., veld1-acc1, ...,
Additional parameters:
s: Struct with work variables, type KPS4
S: The dimension of the state vectorThe number of the point masses of the model N = S/6, the state of each point is represented by two 3 element vectors.
residual!(res, yd, y::MVector{S, SimFloat}, s::KPS3, _) where S
N-point tether model, one point kite at the top:
Inputs:
State vector y = pos1, pos2, ..., posn, vel1, vel2, ..., veln
Derivative yd = vel1, vel2, ..., veln, acc1, acc2, ..., accn
Output:
Residual res = res1, res2 = pos1, ..., vel1, ...
Additional parameters:
s: Struct with work variables, type KPS3
S: The dimension of the state vectorThe number of the point masses of the model N = S/6, the state of each point is represented by two 3 element vectors.
Helper functions
KiteModels.copy_examples — Function
copy_examples()Copy all example scripts to the folder "examples" (it will be created if it doesn't exist). The Project.toml of the examples folder is not copied; it is only valid inside the KiteModels repository.
KiteModels.copy_examples_3d — Function
copy_examples_3d()Copy all 3D example scripts to the folder "examples3d" (it will be created if it doesn't exist). The Project.toml of the examples3d folder is not copied; it is only valid inside the KiteModels repository.
KiteModels.install_examples_3d — Function
install_examples_3d(add_packages=true, overwrite=false)Install 3D examples into the current working directory.
This function copies the examples_3d scripts and required helper files. If add_packages is true, it also installs the packages used by the 3D example scripts. If overwrite is false, existing files are kept.
KiteModels.copy_bin — Function
copy_bin()Copy the scripts createsysimage and run_julia to the folder "bin" (it will be created if it doesn't exist).
KiteModels.calc_drag — Function
calc_drag(s::KPS3, v_segment, unit_vector, rho, v_app_perp, area)Calculate the drag of one tether segment, result stored in s.last_tether_drag and v_app_perp. Return the norm of the apparent wind velocity of the segment.
KiteModels.calculate_rotational_inertia! — Function
calculate_rotational_inertia!(s::AKM, include_kcu::Bool=true, around_kcu::Bool=false)Calculate the rotational inertia (Ixx, Ixy, Ixz, Iyy, Iyz, Izz) for a kite model from settings. Modifies the kite model by initializing the masses.
Parameters:
- X: x-coordinates of the point masses.
- Y: y-coordinates of the point masses.
- Z: z-coordinates of the point masses.
- M: masses of the point masses.
include_kcu: Include the kcu in the rotational inertia calculation?around_kcu: Uses the kcu as the rotation point.
Returns: The tuple Ixx, Ixy, Ixz, Iyy, Iyz, Izz where:
- Ixx: rotational inertia around the x-axis.
- Ixy: rotational inertia around the xy-plane.
- Ixz: rotational inertia around the xz-plane.
- Iyy: rotational inertia around the y-axis.
- Iyz: rotational inertia around the yz-plane.
- Izz: rotational inertia around the z-axis.
KiteModels.calc_set_cl_cd! — Function
calc_set_cl_cd!(s::KPS3, vec_c, v_app)Calculate the lift over drag ratio as a function of the direction vector of the last tether segment, the current depower setting and the apparent wind speed. Set the calculated CL and CD values in the struct s.
KiteModels.calc_aero_forces! — Function
calc_aero_forces!(s::KPS4, pos, vel, rho, alpha_depower, rel_steering)Calculates the aerodynamic forces acting on the kite particles with calc_aero_forces and adds them to s.forces. Also stores the kite reference frame, the angles of attack and the lift, drag and side forces in s.
KiteModels.calc_aero_forces — Function
calc_aero_forces(s::KPS4, pos, vel, rho, alpha_depower, rel_steering)Calculates the aerodynamic forces acting on the kite particles without changing s.
Parameters:
- pos: vector of the particle positions
- vel: vector of the particle velocities
- rho: air density [kg/m^3]
- alpha_depower: depower angle [degrees]
- rel_steering: value between -1.0 and +1.0
Returns a named tuple with the kite reference frame x, y, z, the side_slip, the angles of attack alphas [degrees], the side lift coefficient side_cl, the lift forces L2, L3, L4, the drag forces D2, D3, D4, the pitch damping and steering forces f_d and f_s and the resulting forces on the kite particles f_A, f_B, f_C and f_D. Like s.forces, all forces have the opposite sign of the physical forces.
KiteModels.calc_aero_force_moment — Function
calc_aero_force_moment(s::KPS4)Total aerodynamic force and moment acting on the kite, both resolved in the KA body frame (aft-right-up). The moment is taken about the origin of the KA (and KS) frame, the centre between the kite particles C and D, and includes the pitch damping and steering couples. Uses the positions s.pos, the velocities s.vel and the kite reference frame of the last call of calc_aero_forces!.
Returns a tuple (force, moment) of two SVec3 in [N] and [Nm].
KiteModels.aero_point_forces — Function
aero_point_forces(s::KPS4)Aerodynamic forces on the kite particles A, B, C and D in ENU, including the pitch damping and steering couples, for the positions s.pos and velocities s.vel.
Returns a tuple (f_A, f_B, f_C, f_D) of four SVec3 in [N].
KiteModels.calc_turn_rates — Function
calc_turn_rates(s::KPS4)Angular velocity of the kite, resolved in the KA body frame (aft-right-up). It is calculated from the positions s.pos and velocities s.vel of the kite particles B, C and D, which define the kite reference frame.
Returns an SVec3 in [rad/s].
calc_turn_rates(orient_0, orient_1, dt)Turn rates in the body frame of a kite that turned from the orientation orient_0 to the orientation orient_1 (quaternions [w, x, y, z], KA convention) in the time dt. Zero if dt is not positive or orient_0 is not set (all zero).
Returns an SVec3 in [rad/s].
KiteModels.calc_pitch_rate — Function
calc_pitch_rate(s::KPS4)Time derivative of the pitch angle of orient_euler in [rad/s], calculated from the angular velocity of the kite, so from the positions and velocities of the particles. next_step! approximates the same rate by the change of the pitch angle during the last time step.
KiteModels.calc_particle_forces! — Function
calc_particle_forces!(s::KPS4, pos1, pos2, vel1, vel2, spring, segments, d_tether, rho, i)Calculate the drag force of the tether segment, defined by the parameters pos1, pos2, vel1 and vel2 and distribute it equally on the two particles, that are attached to the segment. The result is stored in the array s.forces.
KiteModels.calc_spring_force — Function
calc_spring_force(s::KPS4, spring, norm1, spring_vel, segments, i; damping=true)Scalar force of the spring i with the length norm1 [m] and the elongation rate spring_vel [m/s], positive for tension: the elastic force, with a reduced stiffness under compression, plus the damping force. The residual and spring_forces use it.
calc_spring_force(s::KPS3, norm1, spring_vel; damping=true)Scalar force of a tether segment with the length norm1 [m] and the elongation rate spring_vel [m/s], positive for tension: the elastic force, with a reduced stiffness under compression, plus the damping force. The residual and spring_forces use it.
KiteModels.calc_drag_forces — Function
calc_drag_forces(s::KPS4, unit_vector, norm1, vel1, vel2, v_wind_tether, segments, d_tether,
rho, i)Drag force of the tether segment or bridle line i with the direction unit_vector and the length norm1, half of which acts on each of its two particles, and the drag force of the KCU, which is zero except for the last tether segment (i == segments). Like s.forces, both have the opposite sign of the physical forces.
Returns a tuple (half_drag_force, kcu_drag_force).
KiteModels.calc_drag_force — Function
calc_drag_force(s::KPS3, v_segment, unit_vector, rho, area)Calculate the drag of one tether segment or of the bridle without changing s. Like s.forces, the drag force has the opposite sign of the physical force.
Returns a tuple (drag, v_apparent, v_app_perp) of the drag force, the apparent wind velocity and its component perpendicular to unit_vector.
KiteModels.tether_drag_forces — Function
tether_drag_forces(s::KPS4)Drag forces of the tether, the bridle lines and the KCU on each particle in ENU, for the positions s.pos and velocities s.vel. The wind is calculated as in inner_loop!.
Returns an SVector with one SVec3 per particle in [N].
tether_drag_forces(s::KPS3)Drag forces of the tether and the bridle on each particle in ENU, for the positions s.pos and the velocities of particle_velocities, distributed on the particles as in residual!.
Returns an SVector with one SVec3 per particle in [N].
KiteModels.particle_velocities — Function
particle_velocities(s::KPS3)Velocities of the particles in ENU from the state vector of the integrator; zero before init!.
Returns an SVector with one SVec3 per particle in [m/s].
KiteModels.UNUSED_FIELDS — Constant
fields of SysState that KPS3 and KPS4 do not use
KiteModels.UNUSED_FIELDS_KPS3 — Constant
fields of SysState that KPS3 does not use: UNUSED_FIELDS, the angles of the four-point kite and the aerodynamic moment, which is always zero for a point mass
KiteModels.inner_loop! — Function
inner_loop!(s::KPS4, pos, vel, v_wind_gnd, segments, d_tether)Calculate the forces, acting on all particles.
Output:
- s.forces
s.v_wind_tether
KiteModels.loop! — Function
loop!(s::KPS4, pos, vel, posd, veld)Calculate the vectors s.res1 and calculate s.res2 using loops that iterate over all tether segments.
KiteModels.make_jac — Function
make_jac(f!, n_vars)Create an explicit Jacobian function using central finite differences.
Works around NLSolversBase >= 7.10 producing subnormal Jacobian entries via DifferentiationInterface, which cause NaN in NLsolve autoscale (subnormal column norms squared underflow to zero).